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


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

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


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

示例1: Execute


//.........这里部分代码省略.........
            REQUEST_VIEW_PLAYER& Recv = pRelationPacket->m_ViewPlayer;

            if ( strlen( Recv.GetTargetName() ) > 0 )
            {
                pTargetUser = g_pOnlineUser->FindUser( Recv.GetTargetName() );
            }

            if ( pTargetUser == NULL )
            { // 玩家可能不存在也可能不在线
                uErr = RET_ERR_TARGETNOTEXIST;

                Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s not find!",
                    Recv.GetTargetName() );
                break;
            }

            Msg.GetRelation()->m_Type = RET_VIEWPLAYER;

            RETURN_VIEW_PLAYER& Send = Msg.GetRelation()->m_ViewPlayer;
            Send.CleanUp();

            // 填充数据
            Send.SetGUID( pTargetUser->GetGUID() );
            Send.SetName( pTargetUser->GetName() );
            // ...

            Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...View Player: %s!",
                pTargetUser->GetName() );
        }
        break;
    case REQ_ADDFRIEND:
    case REQ_TEMPFRIEND_TO_FRIEND:
        { // 检查需要添加的好友是否在线,并发回新好友的详细信息,这里不做合法性判断
            REQUEST_ADD_RELATION_WITH_GROUP& ReqRelation = pRelationPacket->m_AddRelationWithGroup;

            if ( ReqRelation.GetTargetGUID() != INVALID_ID )
            {
                pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetGUID() );
            }
            else if ( strlen(ReqRelation.GetTargetName()) > 0 )
            {
                pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetName() );
            }

            if ( pTargetUser == NULL )
            { //没有发现在“在线用户列表”里对应此名字的用户
                uErr = RET_ERR_TARGETNOTEXIST;

                Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s not find!",
                    ReqRelation.GetTargetName() );
                Assert( FALSE && "找不到该好友" );
                break;
            }

            // 判断 pTargetUser 是否拒绝被加为好友
            if ( pTargetUser->IsCannotAddFriend() )
            {
                uErr = RET_ERR_CANNOT_ADDFRIEND;

                Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s can't be added!",
                    ReqRelation.GetTargetName() );
                break;
            }

            if( pUser->IsEnemy( pTargetUser->GetUserCampData() ) )
            {
开发者ID:gangzi4494,项目名称:web-pap,代码行数:67,代码来源:GWRelationHandler.cpp

示例2: Execute


//.........这里部分代码省略.........
			Send.SetName( pTargetUser->GetName() );
			// ...

			Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...View Player: %s!",
				pTargetUser->GetName() );
		}
		break;

	case REQ_FRIENDADDPOINT:
		{
			REQUEST_RELATION_INFO& RegRelation = pRelationPacket->m_RequestInfo;

			if ( strlen( RegRelation.GetTargetName() ) > 0 )
			{
				pTargetUser = g_pOnlineUser->FindUser( RegRelation.GetTargetName() );
			}

			if ( pTargetUser == NULL )
			{ // 玩家可能不存在也可能不在线
				uErr = RET_ERR_TARGETNOTEXIST;

				Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s not find!",
					RegRelation.GetTargetName() );
				break;
			}
			
			pUser->SetPoint( RegRelation.GetTargetGUID(), pTargetUser->GetGUID() );

			return PACKET_EXE_CONTINUE;
		}
		break;
	case REQ_REJECTADDFRIEND:
		{ //被邀请的人传回来拒绝接受添加好友的请求
			REQUEST_ADD_RELATION_WITH_GROUP& ReqRelation = pRelationPacket->m_AddRelationWithGroup;

			if ( ReqRelation.GetTargetGUID() != INVALID_ID )
			{
				pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetGUID() );
			}
			else if ( strlen(ReqRelation.GetTargetName()) > 0 )
			{
				pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetName() );
			}
			if ( pTargetUser == NULL )
			{ //如果邀请的人不在线,则不向邀请人发送任何消息
				return PACKET_EXE_CONTINUE;
			}

			//如果被邀请的人掉线,则给邀请人返回掉线提示信息
			if ( pTargetUser->UserStatus() == US_OFFLINE )
			{
				return PACKET_EXE_CONTINUE;
			}

			//向邀请人发送拒绝接受加为好友邀请的信息
			WGRelation NotifyMsg;

			NotifyMsg.GetRelation()->CleanUp();
			NotifyMsg.GetRelation()->SetPlayerID( pTargetUser->GetPlayerID() );
			NotifyMsg.GetRelation()->m_Type = RET_REJECTADDFRIEND;
			NotifyMsg.GetRelation()->m_NotifyFriend.CleanUp();
			NotifyMsg.GetRelation()->m_NotifyFriend.SetGUID( pUser->GetGUID() );
			NotifyMsg.GetRelation()->m_NotifyFriend.SetName( pUser->GetName() );

			ServerPlayer* pTServerPlayer = g_pServerManager->GetServerPlayer( pTargetUser->GetServerID() );
			if( pTServerPlayer==NULL )
开发者ID:,项目名称:,代码行数:67,代码来源:


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