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


C++ USER::GetUserSimpleData方法代码示例

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


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

示例1: Execute

UINT GWFingerHandler::Execute(GWFinger* pPacket,Player* pPlayer)
{
__ENTER_FUNCTION

	ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer;
	GW_FINGER* pRecv = pPacket->GetFinger();

	USER* pUser = g_pOnlineUser->FindUser( pRecv->GetGUID() );
	if ( pUser == NULL )
	{ //没有发现在“在线用户列表”里对应此 GUID 的用户
		Log::SaveLog( WORLD_LOGFILE, "GWFingerHandler...User GUID=%X not find!",
			pRecv->GetGUID() );

		return PACKET_EXE_CONTINUE;
	}

	WGFinger Msg;
	WG_FINGER* pSend = Msg.GetFinger();
	pSend->CleanUp();
	pSend->SetPlayerID( pUser->GetPlayerID() );

	switch( pRecv->m_Type )
	{
	case FREQ_GUID:	// GUID 搜索
		{
			GUID_t guid = pRecv->m_FingerByGUID.GetTargetGUID();
			BOOL bOnlineFlag = pRecv->m_FingerByGUID.GetOnlineFlag();
			USER* pTargetUser;

			// 先从 OnlineUser 中查找
			pTargetUser = g_pOnlineUser->FindUser(guid);

			// 找到了直接返回
			if ( pTargetUser != NULL )
			{
				pSend->m_Type = FRET_PLAYERLIST;
				pSend->m_FingerPlayerList.CleanUp();
				pSend->m_FingerPlayerList.AddPlayerInfo( pTargetUser->GetUserSimpleData() );
				FINGER_PLAYER_INFO* pPlayerInfo;
				pPlayerInfo = pSend->m_FingerPlayerList.GetLastPlayerInfo();
				Assert( pPlayerInfo );
				pPlayerInfo->SetOnlineFlag( TRUE );
				pPlayerInfo->SetGuildName( g_pGuildManager->GetGuildName(pPlayerInfo->GetGuildID()) );
			}
			else if ( bOnlineFlag )
			{ // 没有找到则判断是否需要查找离线玩家,不需要返回错误消息
				pSend->m_Type = FRET_ERR_NORESULT;
			}
			else
			{ // 需要则从离线玩家中查找
				pSend->m_Type = FRET_PLAYERLIST;
				pSend->m_FingerPlayerList.CleanUp();

				if ( g_pAllUser->Select( guid, &(pSend->m_FingerPlayerList) ) < 1 )
				{ // 找到了返回,否则返回错误消息
					pSend->m_Type = FRET_ERR_NORESULT;
				}
			}
		}
		break;
	case FREQ_NAME: // NAME 搜索
		{
			const CHAR* szName = pRecv->m_FingerByName.GetTargetName();
			BOOL bOnlineFlag = pRecv->m_FingerByName.GetOnlineFlag();
			BOOL bPreciseFlag = pRecv->m_FingerByName.GetPreciseFlag();
			INT nPosition = pRecv->m_FingerByName.GetPosition();

			pSend->m_FingerPlayerList.CleanUp();

			BOOL bRes;
			if ( bOnlineFlag )
			{ // 在线查找
				bRes = g_pOnlineUser->Select( szName, &(pSend->m_FingerPlayerList), bPreciseFlag, nPosition ) > 0;
			}
			else
			{ // 离线查找
				bRes = g_pAllUser->Select( szName, &(pSend->m_FingerPlayerList), bPreciseFlag, nPosition ) > 0;
			}

			if ( bRes )
			{ //	找到了
				//用FindUser模糊查找怎么办?,而且pSend->m_FingerPlayerList中已保存有玩家信息。修改:王勇鸷
				//USER *pTargetUser = g_pOnlineUser->FindUser(pRecv->m_FingerByName.GetTargetName());
				//pSend->m_FingerPlayerList.CleanUp();
				//pSend->m_FingerPlayerList.AddPlayerInfo( pTargetUser->GetUserSimpleData() );
				//FINGER_PLAYER_INFO* pPlayerInfo;
				//pPlayerInfo = pSend->m_FingerPlayerList.GetLastPlayerInfo();
				//Assert( pPlayerInfo );
				//pPlayerInfo->SetOnlineFlag( TRUE );

				pSend->m_Type = FRET_PLAYERLIST;
			}
			else
			{ //	没找到
				pSend->m_Type = FRET_ERR_NORESULT;
			}
		}
		break;
	case FREQ_ADVANCED:	// 高级搜索
		{
//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:wx2Server,代码行数:101,代码来源:GWFingerHandler.cpp


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