当前位置: 首页>>代码示例>>C++>>正文


C++ CUser::GetId方法代码示例

本文整理汇总了C++中CUser::GetId方法的典型用法代码示例。如果您正苦于以下问题:C++ CUser::GetId方法的具体用法?C++ CUser::GetId怎么用?C++ CUser::GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CUser的用法示例。


在下文中一共展示了CUser::GetId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Join

// function CChatRoom::Join
//  Joins a user to this chatroom
bool CChatRoom::Join(int user)
{
	if ( !m_bActive )
	{
		CLog::Error("Could not join chat room - Chat not intialized", __FUNCTION__);
		return false;
	}
	Pthread_mutex_lock(&CUser::m_UserMutex, __FUNCTION__);
	CUser* currUser = CUser::GetUser(user);
	if ( currUser == 0 )
	{
		CLog::Error("User id %d not found", __FUNCTION__, user);
		Pthread_mutex_unlock(&CUser::m_UserMutex, __FUNCTION__);
		return false;
	}
	Pthread_mutex_lock(&m_InsideUsersMutex, __FUNCTION__);

	// the only time this is a linear search is when someone logs in and logs out

	list<int>::iterator iter = m_UsersInside.begin();

	while ( iter != m_UsersInside.end() )
	{
		if ( *iter == user )
		{
			// if user is already in the chat room, refuse entry
			CLog::Record("Failed to login to chat room %s - %d already in there", GetName().c_str(), *iter );
			Pthread_mutex_unlock(&m_InsideUsersMutex, __FUNCTION__);
			Pthread_mutex_unlock(&CUser::m_UserMutex, __FUNCTION__);
			return false;
		}
		iter++;
	}
/*
	//	size_t BufferSize = 9 + (MAXNAME+7)*users, namelen;
	if ( m_sName.length() >= MAXCHATNAMELEN )
		namelen = MAXCHATNAMELEN;
	else
		namelen = m_sName.length()+1;
//	BufferSize += namelen;
*/
//	char* LoggedInBuffer = new char[BufferSize];
	size_t users = m_UsersInside.size();

	char LoggedInBuffer[9];
	char* temp = LoggedInBuffer;
	*temp = PACK_JOINCHAT;
	temp++;
	*(int*)temp = this->m_ChatID;
	temp += 4;
	*(int*)temp = (int)users;
	temp += 4;

	currUser->SendTo(LoggedInBuffer, 9);

	vector<int> toKick;
	char CurrUserData[MAXNAME+MAXCLAN+9];
	temp = CurrUserData;
	*temp = PACK_USERENTERCHAT;
	temp++;
	*(int*)temp = this->m_ChatID;
	temp += sizeof(int);
	*(int*)temp = currUser->GetId();
	temp += sizeof(int);
	strncpy(temp, currUser->GetName(), MAXNAME);
	temp += MAXNAME;
	strncpy(temp, currUser->GetClan(), MAXCLAN);
	
	for ( iter = m_UsersInside.begin(); iter != m_UsersInside.end(); iter++ )
	{
		char UserData[MAXNAME+MAXCLAN+4];
		temp = UserData;
		CUser* currUser2 = CUser::GetUser(*iter);
		// this really shouldnt happen either, we checked for it earlier
		if ( *iter == user ) //|| currUser == 0 )
		{
			Pthread_mutex_unlock(&CUser::m_UserMutex, __FUNCTION__);
			Pthread_mutex_unlock(&m_InsideUsersMutex, __FUNCTION__);
			return false;
		}
		// this shouldn't happen, but if we come across a user with a null pointer, we kick him/her from the room
		if ( currUser2 == 0 )
		{
			//**** Send a boot message to everyone in the chatroom
			toKick.push_back(*iter);
			m_UsersInside.erase(iter);
			continue;
		}
		CLog::Record("Sending PACK_USERENTERCHAT to %s", currUser2->GetName());
		currUser2->SendTo(CurrUserData, MAXNAME+MAXCLAN+9);
		*(int*)temp = currUser2->GetId();
		temp += sizeof(int);
		strncpy(temp, currUser2->GetName(), MAXNAME);
		temp += MAXNAME;
		// in here goes the clan
		strncpy(temp, currUser2->GetClan(), MAXCLAN);
		temp += MAXCLAN;
		currUser->SendTo(UserData, MAXNAME+MAXCLAN+4);
//.........这里部分代码省略.........
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:101,代码来源:ChatRoom.cpp

示例2: DoUsePartySkill


//.........这里部分代码省略.........
												if( pLeader->IsNearPC( pMember ) )
													pMember->AddPartySkillBlitz( pLeader->m_idSetTarget );		// 각 멤버들에게 단장타겟으로 잡은 무버의 아이디를 보냄.
											}
										}
									}
								}
								else
								{
									pLeader->AddSendErrorParty( ERROR_NOTTARGET, ST_BLITZ );
								}
							}
							else
							{
								pLeader->AddSendErrorParty( ERROR_NOTTARGET, ST_BLITZ );
								// 타겟을 안잡았다.
							}
						}
						break;
					case ST_RETREAT:
						{
							g_DPCoreClient.SendRemovePartyPoint( uPartyId, pItemProp->dwExp );
							// 후퇴 표시
							CUser *pLeader = g_UserMng.GetUserByPlayerID( m_aMember[0].m_uPlayerId );	// 리더의 포인터
							if( IsValidObj( pLeader ) == FALSE )
								break;

							for( i = 0; i < m_nSizeofMember; i ++ )
							{
								pMember		= g_UserMng.GetUserByPlayerID( m_aMember[i].m_uPlayerId );
								if( IsValidObj( (CObj*)pMember ) )
								{
									if( m_nModeTime[PARTY_GIFTBOX_MODE] || m_nModeTime[PARTY_FORTUNECIRCLE_MODE] )
									{
										pMember->AddHdr( pMember->GetId(), SNAPSHOTTYPE_PARTYSKILL_RETREAT );
									}
									else
									{
										if( pLeader->IsNearPC( pMember ) )
											pMember->AddHdr( pMember->GetId(), SNAPSHOTTYPE_PARTYSKILL_RETREAT );
									}
								}
							}
						}
						break;
					case ST_SPHERECIRCLE:
						{
							// 크리티컬 확률
							CUser *pLeader = g_UserMng.GetUserByPlayerID( m_aMember[0].m_uPlayerId );	// 리더의 포인터
							if( IsValidObj( pLeader ) == FALSE )
								break;
							
							if( pLeader->m_idSetTarget != NULL_ID )
							{
								CMover * pT = prj.GetMover( pLeader->m_idSetTarget );
								if( pT && !pT->IsPlayer() )
								{
									g_DPCoreClient.SendRemovePartyPoint( uPartyId, pItemProp->dwExp );
									for( i = 0; i < m_nSizeofMember; i ++ )
									{
										pMember		= g_UserMng.GetUserByPlayerID( m_aMember[i].m_uPlayerId );
										if( IsValidObj( (CObj*)pMember ) )
										{
											if( m_nModeTime[PARTY_GIFTBOX_MODE] || m_nModeTime[PARTY_FORTUNECIRCLE_MODE] )
											{
												pMember->AddHdr( pLeader->m_idSetTarget, SNAPSHOTTYPE_PARTYSKILL_SPHERECIRCLE );
												pMember->m_dwFlag |= MVRF_CRITICAL;
开发者ID:KerwinMa,项目名称:AerothFlyffSource,代码行数:67,代码来源:party.cpp


注:本文中的CUser::GetId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。