예제 #1
0
UINT GWRelationHandler::Execute( GWRelation* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION

    ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer;
    GW_RELATION* pRelationPacket = pPacket->GetRelation();
    WGRelation Msg;
    Msg.GetRelation()->CleanUp();
    Msg.SetGUID(pRelationPacket->GetGUID());
    UCHAR uErr = 0;

    _RELATION* pRelationData = NULL;
    USER* pTargetUser = NULL;

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

        Assert( FALSE && "找不到信息发送者" );
        return PACKET_EXE_CONTINUE;
    }

    Msg.GetRelation()->SetPlayerID( pUser->GetPlayerID() );

    switch( pRelationPacket->m_Type )
    {
    case REQ_RELATIONINFO:
        {
            REQUEST_RELATION_INFO& ReqRelation = pRelationPacket->m_RequestInfo;

            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 )
            { // 玩家可能不存在也可能不在线,由 Server 来判断
                uErr = RET_TARGETNOTONLINE;

                Msg.GetRelation()->m_RelationGUID.CleanUp();
                Msg.GetRelation()->m_RelationGUID.SetTargetGUID( ReqRelation.GetTargetGUID() );

                Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User GUID=%X not find!",
                    ReqRelation.GetTargetGUID() );
                break;
            }

            Msg.GetRelation()->m_Type = RET_RELATIONINFO;

            RETURN_RELATION_INFO& Relation = Msg.GetRelation()->m_RelationInfo;

            Relation.CleanUp();

            pRelationData = Relation.GetRelationData();
            // pRelationData 的数据在 switch 之后填充

            Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...get User info of Name=%s!",
                pTargetUser->GetName() );
        }
        break;
    case REQ_VIEWPLAYER:
        {
            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() ) )
            {
                uErr = RET_ERR_ISENEMY;

                Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s is enemy!",
                    ReqRelation.GetTargetName() );
                break;
            }

            RELATION_TYPE RelationType = pUser->GetRelationType( pTargetUser->GetGUID() );
            if ( RelationType != RELATION_TYPE_NONE )
            {
                if ( RelationType == RELATION_TYPE_BLACKNAME )
                {
                    uErr = RET_ERR_ISBLACKNAME;
                }
                else
                {
                    uErr = RET_ERR_ISFRIEND;
                }

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

            // 加入好友名单
            _RELATION_USER RUser;
            RUser.m_UserGUID = pTargetUser->GetGUID();
            RUser.m_RelationType = RELATION_TYPE_FRIEND;
            RUser.m_nFriendPoint = 0;
            pUser->AddRelation( pTargetUser->GetGUID(), &RUser );

            // 传回去在线信息
            if ( pRelationPacket->m_Type == REQ_ADDFRIEND )
            {
                Msg.GetRelation()->m_Type = RET_ADDFRIEND;
            }
            else if ( pRelationPacket->m_Type == REQ_TEMPFRIEND_TO_FRIEND )
            {
                Msg.GetRelation()->m_Type = RET_TEMPFRIEND_TO_FRIEND;
            }

            RETURN_ADD_RELATION& Relation = Msg.GetRelation()->m_AddRelation;

            Relation.CleanUp();
            Relation.SetRelationType( ReqRelation.GetRelationType() );
            Relation.SetGroup( ReqRelation.GetGroup() );

            pRelationData = Relation.GetRelationData();
            // pRelationData 的数据在 switch 之后填充

            Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s added to friend list!",
                ReqRelation.GetTargetName() );

            if ( pTargetUser->UserStatus() == US_NORMAL )
            { // 通知被加的人
                WGRelation NotifyMsg;

                NotifyMsg.GetRelation()->CleanUp();
                NotifyMsg.GetRelation()->SetPlayerID( pTargetUser->GetPlayerID() );
                NotifyMsg.GetRelation()->m_Type = RET_ADDFRIENDNOTIFY;
                RETURN_NOTIFY_FRIEND& NotifyFriend = NotifyMsg.GetRelation()->m_NotifyFriend;

                NotifyFriend.CleanUp();
                NotifyFriend.SetGUID( pUser->GetGUID() );
                NotifyFriend.SetName( pUser->GetName() );

                ServerPlayer* pTServerPlayer = g_pServerManager->GetServerPlayer( pTargetUser->GetServerID() );
                if( pTServerPlayer==NULL )
                {
                    Assert(FALSE);
                    break;
                }

                pTServerPlayer->SendPacket( &NotifyMsg );
            }
        }
        break;
    case REQ_ADDTOBLACKLIST:
    case REQ_TEMPFRIEND_ADDTO_BLACKLIST:
        { // 检查需要添加的是否在线,并发回详细信息,这里不做合法性判断
            REQUEST_ADD_RELATION& ReqRelation = pRelationPacket->m_AddRelation;

            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;
            }

            RELATION_TYPE RelationType = pUser->GetRelationType( pTargetUser->GetGUID() );
            if ( RelationType != RELATION_TYPE_NONE )
            {
                if ( RelationType == RELATION_TYPE_FRIEND )
                {
                    pUser->DelRelation( pTargetUser->GetGUID() );
                }
                else
                {
                    switch( RelationType )
                    {
                    case RELATION_TYPE_BLACKNAME:
                        uErr = RET_ERR_ISBLACKNAME;
                        break;
                    case RELATION_TYPE_MARRY:
                        uErr = RET_ERR_SPOUSETOBLACKLIST;
                        break;
                    case RELATION_TYPE_MASTER:
                        uErr = RET_ERR_MASTERTOBLACKLIST;
                        break;
                    case RELATION_TYPE_PRENTICE:
                        uErr = RET_ERR_PRENTICETOBLACKLIST;
                        break;
                    case RELATION_TYPE_BROTHER:
                        uErr = RET_ERR_BROTHERTOBLACKLIST;
                        break;
                    default:
                        Assert(FALSE);
                        return PACKET_EXE_CONTINUE;
                    }

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

            // 加入黑名单
            _RELATION_USER RUser;
            RUser.m_UserGUID = pTargetUser->GetGUID();
            RUser.m_RelationType = RELATION_TYPE_BLACKNAME;
            RUser.m_nFriendPoint = 0;
            pUser->AddRelation( pTargetUser->GetGUID(), &RUser );

            // 传回去在线信息
            if ( pRelationPacket->m_Type == REQ_ADDTOBLACKLIST )
            {
                Msg.GetRelation()->m_Type = RET_ADDTOBLACKLIST;
            }
            else if ( pRelationPacket->m_Type == REQ_TEMPFRIEND_ADDTO_BLACKLIST )
            {
                Msg.GetRelation()->m_Type = RET_TEMPFRIEND_ADDTO_BLACKLIST;
            }

            RETURN_ADD_RELATION& Relation = Msg.GetRelation()->m_AddRelation;

            Relation.CleanUp();
            Relation.SetRelationType( ReqRelation.GetRelationType() );

            pRelationData = Relation.GetRelationData();
            // pRelationData 的数据在 switch 之后填充

            Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s added to black list!",
                ReqRelation.GetTargetName() );
        }
        break;
    case REQ_DELFRIEND:
    case REQ_DELFROMBLACKLIST:
        pUser->DelRelation( pRelationPacket->m_RelationGUID.GetTargetGUID() );
        return PACKET_EXE_CONTINUE;
    case REQ_TRANSITION:
        {
            RELATION_GUID_UCHAR& Relation = pRelationPacket->m_TransitionRelation;
            pUser->DelRelation( Relation.GetTargetGUID() );

            _RELATION_USER RUser;
            RUser.m_UserGUID = Relation.GetTargetGUID();
            RUser.m_RelationType = (RELATION_TYPE)Relation.GetRelationType();
            RUser.m_nFriendPoint = 0;
            pUser->AddRelation( Relation.GetTargetGUID(), &RUser );
            return PACKET_EXE_CONTINUE;
        }
        break;
    case REQ_NEWGOODFRIEND:
        { // 加入一个亲密好友
            pUser->AddGoodFriend( pRelationPacket->m_RelationGUID.GetTargetGUID() );
            return PACKET_EXE_CONTINUE;
        }
        break;
    case REQ_RELATIONONLINE:
        { // 获取密友的在线列表
            Msg.GetRelation()->m_Type = RET_ONLINELIST;
            RETURN_ONLINE_LIST* pSend = &(Msg.GetRelation()->m_RelationOnline);
            pSend->CleanUp();
            pUser->FillOnlineList(pSend);
        }
        break;
    case REQ_MODIFYMOOD:
        {
            pUser->SetMood( pRelationPacket->m_ModifyMood.GetMood() );
            return PACKET_EXE_CONTINUE;
        }
        break;
    case REQ_MODIFYSETTINGS:
        {
            pUser->SetSettings( pRelationPacket->m_Settings.GetSettings() );
            return PACKET_EXE_CONTINUE;
        }
        break;
    case REQ_NOTIFY_ADDTEMPFRIEND:
        {
            REQUEST_VIEW_PLAYER& Recv = pRelationPacket->m_ViewPlayer;

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

            if ( pTargetUser == NULL )
            { // 玩家可能不存在也可能不在线,由 Server 来判断
                Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User GUID=%s not find!",
                    Recv.GetTargetName() );
                return PACKET_EXE_CONTINUE;
            }

            Msg.GetRelation()->m_Type = RET_NOTIFY_ADDTEMPFRIEND;
            REQUEST_VIEW_PLAYER* pSend = &(Msg.GetRelation()->m_PlayerName);
            pSend->CleanUp();
            pSend->SetTargetName( pUser->GetName() );
        }
        break;
    default :
        {
            Assert(FALSE);
            return PACKET_EXE_CONTINUE;
        }
    }

    if ( uErr > 0 )
    {
        Msg.GetRelation()->m_Type = uErr;
    }

    if ( pRelationData != NULL && pTargetUser != NULL )
    {
        pRelationData->SetGUID( pTargetUser->GetGUID() );
        pRelationData->SetName( pTargetUser->GetName() );
        pRelationData->SetLevel( pTargetUser->GetLevel() );
        pRelationData->SetMenPai( pTargetUser->GetMenpai() );
        pRelationData->SetPortrait( pTargetUser->GetPortrait() );
        pRelationData->SetGuildID( pTargetUser->GetGuildID() );
        pRelationData->SetGuildName( g_pGuildManager->GetGuildName(pTargetUser->GetGuildID()) );

        if ( pTargetUser->UserStatus() == US_NORMAL )
        { // 只有在线才发剩余信息
            pRelationData->SetOnlineFlag(1);
            pRelationData->SetMood( pTargetUser->GetMood() );
            pRelationData->SetTitle( pTargetUser->GetTitle() );
            pRelationData->SetSceneID( pTargetUser->GetSceneID() );

            if ( pTargetUser->GetTeamID() != INVALID_ID )
            {
                Team* pTeam = g_pTeamList->GetTeam( pTargetUser->GetTeamID() );
                if ( pTeam != NULL )
                {
                    pRelationData->SetTeamSize( pTeam->MemberCount() );
                }
            }
        }
    }

    pServerPlayer->SendPacket( &Msg );

    return PACKET_EXE_CONTINUE;

__LEAVE_FUNCTION

    return PACKET_EXE_ERROR;
}
uint GWTeamRetApplyHandler::Execute( GWTeamRetApply* pPacket, Player* pPlayer )
{
    __ENTER_FUNCTION

    GUID_t sGuid = pPacket->GetSourGUID();//申请人的GUID
    GUID_t lGuid = pPacket->GetLeaderGUID();//队长的GUID

    USER* pLeaderUser = g_pOnlineUser->FindUser( lGuid );
    if( pLeaderUser==NULL )
    {
        Log::SaveLog( WORLD_LOGFILE, "GWTeamRetApplyHandler...User Leader GUID=%X not find!",
                      lGuid );

        return PACKET_EXE_CONTINUE;
    }

    ServerPlayer* pLeaderServerPlayer = (ServerPlayer*)pPlayer;

    USER* pSourUser = g_pOnlineUser->FindUser( sGuid );
    if( pSourUser==NULL )
    {
        if( pPacket->GetReturn()==TRUE )
        {
            WGTeamError dMsg;
            dMsg.SetPlayerID( pLeaderUser->GetPlayerID() );
            dMsg.SetGUID( pLeaderUser->GetGUID() );
            dMsg.SetErrorCode( TEAM_ERROR_TARGETNOTONLINE );
            pLeaderServerPlayer->SendPacket( &dMsg );
        }

        Log::SaveLog( WORLD_LOGFILE, "GWTeamRetApplyHandler...User Sour GUID=%X not find!",
                      sGuid );

        return PACKET_EXE_CONTINUE;
    }

    ID_t SourServerID = pSourUser->GetServerID();
    ServerPlayer* pSourServerPlayer = g_pServerManager->GetServerPlayer( SourServerID );
    if( pSourServerPlayer==NULL )
    {
        Assert(FALSE);
        return PACKET_EXE_CONTINUE;
    }

    if( pLeaderUser->IsEnemy( pSourUser->GetUserCampData() ) )
    {
        Log::SaveLog( WORLD_LOGFILE, "GWTeamRetApplyHandler...Lead Name=%s, Invite Name=%s are enemy!",
                      pLeaderUser->GetName(), pSourUser->GetName() );

        return PACKET_EXE_CONTINUE;
    }

    if( pPacket->GetReturn()==FALSE )
    {   //队长不同意
        WGTeamError sMsg;
        sMsg.SetPlayerID( pSourUser->GetPlayerID() );
        sMsg.SetGUID( pLeaderUser->GetGUID() );
        sMsg.SetErrorCode( TEAM_ERROR_APPLYLEADERREFUSE );
        pSourServerPlayer->SendPacket( &sMsg );

        Log::SaveLog( WORLD_LOGFILE, "GWTeamRetApplyHandler...Leader lGUID=%X Refuse sGUID=%X join team!",
                      lGuid, sGuid );
    }
    else if( pSourUser->GetTeamID() != INVALID_ID )
    {   //申请人已经属于某个队伍
        //WGTeamError sMsg;
        //sMsg.SetPlayerID( pSourUser->m_PlayerID );
        //sMsg.SetErrorCode( TEAM_ERROR_APPLYSOURHASTEAM );
        //pSourServerPlayer->SendPacket( &sMsg );

        WGTeamError lMsg;
        lMsg.SetPlayerID( pLeaderUser->GetPlayerID() );
        lMsg.SetGUID( pLeaderUser->GetGUID() );
        lMsg.SetErrorCode( TEAM_ERROR_APPLYSOURHASTEAM );
        pLeaderServerPlayer->SendPacket( &lMsg );

        Log::SaveLog( WORLD_LOGFILE, "GWTeamRetApplyHandler...Leader lGUID=%X, sGUID=%X has team!",
                      lGuid, sGuid );
    }
    else
    {   //队伍存在
        TeamID_t tid = pLeaderUser->GetTeamID();
        Team* pTeam = g_pTeamList->GetTeam( tid );
        Assert( pTeam );

        if( pTeam->IsFull() )
        {   //队伍人数已经满了
            WGTeamError sMsg;
            sMsg.SetPlayerID( pSourUser->GetPlayerID() );
            sMsg.SetGUID( pLeaderUser->GetGUID() );
            sMsg.SetErrorCode( TEAM_ERROR_APPLYTEAMFULL );
            pSourServerPlayer->SendPacket( &sMsg );

            WGTeamError lMsg;
            lMsg.SetPlayerID( pLeaderUser->GetPlayerID() );
            lMsg.SetGUID( pLeaderUser->GetGUID() );
            lMsg.SetErrorCode( TEAM_ERROR_TEAMFULL );
            pLeaderServerPlayer->SendPacket( &lMsg );

            Log::SaveLog( WORLD_LOGFILE, "GWTeamRetApplyHandler...Team Full  sGUID=%X lGUID=%X",
                          sGuid, lGuid );
        }
        else if( pTeam->Leader()->m_Member != lGuid )
        {   //队长GUID和队伍中记录的队长GUID不符
            WGTeamError sMsg;
            sMsg.SetPlayerID( pSourUser->GetPlayerID() );
            sMsg.SetGUID( pLeaderUser->GetGUID() );
            sMsg.SetErrorCode( TEAM_ERROR_APPLYLEADERGUIDERROR );
            pSourServerPlayer->SendPacket( &sMsg );

            WGTeamError lMsg;
            lMsg.SetPlayerID( pLeaderUser->GetPlayerID() );
            lMsg.SetGUID( pLeaderUser->GetGUID() );
            lMsg.SetErrorCode( TEAM_ERROR_APPLYLEADERGUIDERROR );
            pLeaderServerPlayer->SendPacket( &lMsg );

            Log::SaveLog( WORLD_LOGFILE, "GWTeamRetApplyHandler...Team Full  sGUID=%X lGUID=%X",
                          sGuid, lGuid );
        }
        else
        {   //加入
            //将玩家加入队伍
            TEAMMEMBER Member;
            Member.m_Member = sGuid;
            pTeam->AddMember( &Member );

            //设置玩家队伍信息
            pSourUser->SetTeamID( pTeam->GetTeamID() );
            WGTeamResult Msg1; // 发给新队员的
            Msg1.SetPlayerID( pSourUser->GetPlayerID() );
            Msg1.SetTeamID( tid );
            WGTeamResult Msg2; // 发给每个队员的
            Msg2.SetReturn( TEAM_RESULT_MEMBERENTERTEAM );
            Msg2.SetTeamID( tid );
            Msg2.SetGUID( sGuid );
            Msg2.SetGUIDEx( pSourUser->GetPlayerID() ); // 将玩家的 PlayerID 传回
            Msg2.SetSceneID( pSourUser->GetSceneID() );
            Msg2.SetName( pSourUser->GetName() );
            Msg2.SetIcon( pSourUser->GetPortrait() );
            Msg2.SetDataID( pSourUser->GetSex() );

            //通知所有组内的玩家
            for( int i=0; i<pTeam->MemberCount(); i++ )
            {
                TEAMMEMBER* pMember = pTeam->Member( i );
                if( pMember==NULL )
                {
                    Assert(FALSE);
                    continue;
                }

                USER* pUser = g_pOnlineUser->FindUser( pMember->m_Member );
                if( pUser==NULL )
                {
                    Assert(FALSE);
                    continue;
                }

                ID_t ServerID = pUser->GetServerID();
                ServerPlayer* pServerPlayer = g_pServerManager->GetServerPlayer( ServerID );
                if( pServerPlayer==NULL )
                {
                    Assert(FALSE);
                    continue;
                }

                Msg2.SetPlayerID( pUser->GetPlayerID() );
                pServerPlayer->SendPacket( &Msg2 );

                if( pMember->m_Member != sGuid )
                {   // 将自己以外的玩家传给新玩家
                    Msg1.SetReturn( TEAM_RESULT_TEAMREFRESH );
                    Msg1.SetName( pUser->GetName() );
                    Msg1.SetIcon( pUser->GetPortrait() );
                    Msg1.SetDataID( pUser->GetSex() );

                    Msg1.SetGUID( pMember->m_Member );
                    Msg1.SetGUIDEx( pUser->GetPlayerID() ); // 将玩家的 PlayerID 传回
                    Msg1.SetSceneID( pUser->GetSceneID() );

                    pSourServerPlayer->SendPacket( &Msg1 );
                }
            }//end for

            Log::SaveLog( WORLD_LOGFILE, "GWTeamRetApplyHandler...Success!  sGUID=%X lGUID=%X",
                          sGuid, lGuid );
        }

    }




    return PACKET_EXE_CONTINUE;

    __LEAVE_FUNCTION

    return PACKET_EXE_ERROR;
}
예제 #3
0
uint GWChatHandler::Execute( GWChat* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION

	ServerPlayer* pSourServerPlayer = (ServerPlayer*)pPlayer ;

	GUID_t SourGUID = pPacket->GetSourGUID() ;

	USER* pSourUser = g_pOnlineUser->FindUser( SourGUID ) ;
	if( pSourUser==NULL )
	{
		Log::SaveLog( WORLD_LOGFILE, "GWChatHandler...User Sour GUID=%X not find!", 
			SourGUID ) ;
		return PACKET_EXE_CONTINUE ;
	}

	WGChat Msg ;
	Msg.SetChatType( pPacket->GetChatType() ) ;
	Msg.SetContexSize( pPacket->GetContexSize() ) ;
	Msg.SetContex( pPacket->GetContex() ) ;
	Msg.SetSourNameSize( (BYTE)(strlen(pSourUser->GetName())) ) ;
	Msg.SetSourName( pSourUser->GetName() ) ;
	Msg.SetCampID( pSourUser->GetUserCampData()->m_nCampID );
	Msg.SetWorldChatID( g_pChatCenter->NextWorldChatID() ) ;

	switch( pPacket->GetChatType() )
	{
	case CHAT_TYPE_NORMAL:
		{
			Assert(FALSE) ;
		}
		break ;
	case CHAT_TYPE_GUILD:
		{
			Msg.SetGuildID( pPacket->GetGuildID() ) ;
			g_pServerManager->BroadCastServer( &Msg ) ;
		}
		break ;
	case CHAT_TYPE_MENPAI:
		{
			Msg.SetMenpaiID( pPacket->GetMenpaiID() ) ;
			g_pServerManager->BroadCastServer( &Msg ) ;
		}
		break ;
	case CHAT_TYPE_SYSTEM:
	case CHAT_TYPE_SCENE:
		{
			g_pServerManager->BroadCastServer( &Msg ) ;
		}
		break ;
	case CHAT_TYPE_TEAM:
		{
			Team* pTeam = g_pTeamList->GetTeam( pSourUser->GetTeamID() ) ;
			if( pTeam==NULL )
				break ;

			for( int i=0; i<pTeam->MemberCount(); i++ )
			{
				TEAMMEMBER* pMember = pTeam->Member( i ) ;
				if( pMember==NULL )
				{
					Assert(FALSE) ;
					continue ;
				}

				USER* pUser = g_pOnlineUser->FindUser( pMember->m_Member ) ;
				if( pUser==NULL )
				{//如果队员离线,则用户数据是空
					continue ;
				}
				
				ID_t ServerID = pUser->GetServerID() ;
				ServerPlayer* pServerPlayer = g_pServerManager->GetServerPlayer( ServerID ) ;
				if( pServerPlayer==NULL )
				{
					Assert(FALSE) ;
					continue ;
				}

				Msg.SetPlayerID( pUser->GetPlayerID() ) ;

				pServerPlayer->SendPacket( &Msg ) ;
			}
		}
		break ;
	case CHAT_TYPE_TELL:
		{
			USER* pUser = g_pOnlineUser->FindUser( pPacket->GetTargetName() ) ;

			if( pUser )
			{
				if( pSourUser->IsEnemy( pUser->GetUserCampData() ) )
					pUser = NULL;	//如果是敌对阵营,处理方法跟查无此人相同!!
									//按道理说是不能密的哦~~
			}

			if( pUser==NULL )
			{//如果队员离线,则用户数据是空
				CHAR* szName="system" ;
				CHAR szContex[32] ;
				sprintf( szContex, "@@%s", pPacket->GetTargetName() ) ;

				WGChat MsgR ;
				MsgR.SetPlayerID( pSourUser->GetPlayerID() ) ;
				MsgR.SetChatType( CHAT_TYPE_SELF ) ;
				MsgR.SetContexSize( sizeof(szContex) ) ;
				MsgR.SetContex( szContex ) ;
				MsgR.SetSourNameSize( (BYTE)(strlen(szName)) ) ;
				MsgR.SetSourName( szName ) ;
				MsgR.SetWorldChatID( g_pChatCenter->NextWorldChatID() ) ;
				MsgR.SetCampID( pSourUser->GetUserCampData()->m_nCampID );
				
				pSourServerPlayer->SendPacket( &MsgR ) ;

				break ;
			}
				
			ID_t ServerID = pUser->GetServerID() ;
			ServerPlayer* pServerPlayer = g_pServerManager->GetServerPlayer( ServerID ) ;
			if( pServerPlayer==NULL )
			{
				Assert(FALSE) ;
				break ;
			}

			Msg.SetPlayerID( pUser->GetPlayerID() ) ;

			pServerPlayer->SendPacket( &Msg ) ;
		}
		break ;
	case CHAT_TYPE_CHANNEL:
		{
			ChatChannel* pChannel = g_pChatCenter->GetChatChannel( pPacket->GetChannelID() ) ;
			if( pChannel==NULL )
				break ;

			for( int i=0; i<pChannel->MemberCount(); i++ )
			{
				GUID_t memberguid = pChannel->Member(i) ;
				if( memberguid==INVALID_ID )
				{
					Assert(FALSE) ;
					continue ;
				}

				USER* pUser = g_pOnlineUser->FindUser( memberguid ) ;
				if( pUser==NULL )
				{//如果队员离线,则用户数据是空
					continue ;
				}
				
				ID_t ServerID = pUser->GetServerID() ;
				ServerPlayer* pServerPlayer = g_pServerManager->GetServerPlayer( ServerID ) ;
				if( pServerPlayer==NULL )
				{
					Assert(FALSE) ;
					continue ;
				}

				Msg.SetPlayerID( pUser->GetPlayerID() ) ;

				pServerPlayer->SendPacket( &Msg ) ;
			}
		}
		break ;
	default :
		{
			Assert(FALSE) ;
		}
		break ;
	};

	g_pChatCenter->PushChatPacket( pPacket ) ;

	Log::SaveLog( WORLD_LOGFILE, "GWChatHandler...GUID=%X ChatType=%d Contex=%s", 
		SourGUID, pPacket->GetChatType(), pPacket->GetContex() ) ;

	return PACKET_EXE_NOTREMOVE ;//不能删除pPacket, 已经放入预存管道

__LEAVE_FUNCTION

	return PACKET_EXE_ERROR ;
}
예제 #4
0
UINT GWTeamRetInviteHandler::Execute( GWTeamRetInvite* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION

    GUID_t sGuid = pPacket->GetSourGUID();//邀请人的GUID
    GUID_t dGuid = pPacket->GetDestGUID();//被邀请人的GUID

    USER* pDestUser = g_pOnlineUser->FindUser( dGuid );
    if( pDestUser==NULL )
    {
        Log::SaveLog( WORLD_LOGFILE, "GWTeamRetInviteHandler...User Dest GUID=%X not find!", 
            dGuid );

        return PACKET_EXE_CONTINUE;
    }

    ServerPlayer* pDestServerPlayer = (ServerPlayer*)pPlayer;

    USER* pSourUser = g_pOnlineUser->FindUser( sGuid );
    if( pSourUser==NULL )
    {
        if( pPacket->GetReturn()==TRUE )
        {
            WGTeamError dMsg;
            dMsg.SetPlayerID( pDestUser->GetPlayerID() );
            dMsg.SetGUID( pDestUser->GetGUID() );
            dMsg.SetErrorCode( TEAM_ERROR_TARGETNOTONLINE );
            pDestServerPlayer->SendPacket( &dMsg );
        }

        Log::SaveLog( WORLD_LOGFILE, "GWTeamRetInviteHandler...User Sour GUID=%X not find!", 
            sGuid );
        return PACKET_EXE_CONTINUE;
    }

    if( pSourUser->IsEnemy( pDestUser->GetUserCampData() ) )
    {
        Log::SaveLog( WORLD_LOGFILE, "GWTeamRetInviteHandler...Sour Name=%X, Dest Name=%s are enemy!", 
            pSourUser->GetName(), pDestUser->GetName() );

        return PACKET_EXE_CONTINUE;
    }

    ID_t SourServerID = pSourUser->GetServerID();
    ServerPlayer* pSourServerPlayer = g_pServerManager->GetServerPlayer( SourServerID );
    if( pSourServerPlayer==NULL )
    {
        Assert(FALSE);
        return PACKET_EXE_CONTINUE;
    }

    USER* pLeader = NULL;
    ServerPlayer* pLeaderServerPlayer;

    if ( pSourUser->GetTeamID() != INVALID_ID )
    {
        Team* pTeam = g_pTeamList->GetTeam( pSourUser->GetTeamID() );

        if ( pTeam == NULL )
        {
            Assert( pTeam );
            pSourUser->SetTeamID( INVALID_ID );
        }
        else if ( pTeam->Leader()->m_Member != sGuid )
        { // 邀请人不是队长
            pLeader = g_pOnlineUser->FindUser( pTeam->Leader()->m_Member );

            pLeaderServerPlayer = g_pServerManager->GetServerPlayer( pLeader->GetServerID() );
            if ( pLeaderServerPlayer == NULL )
            {
                Assert( FALSE );
                pLeader = NULL;
            }
        }
    }


    if( pPacket->GetReturn()==FALSE )
    {//被邀请人不同意加入队伍
        WGTeamError Msg;
        Msg.SetPlayerID( pSourUser->GetPlayerID() );
        Msg.SetGUID( pDestUser->GetGUID() );
        Msg.SetErrorCode( TEAM_ERROR_INVITEREFUSE );

        pSourServerPlayer->SendPacket( &Msg );

        if ( pLeader != NULL )
        {
            Msg.SetPlayerID( pLeader->GetPlayerID() );
            pLeaderServerPlayer->SendPacket( &Msg );
        }

        Log::SaveLog( WORLD_LOGFILE, "GWTeamRetInviteHandler...Invite Refuse SourGUID=%X DestGUID=%X", 
            sGuid, dGuid );
    }
    else if( pDestUser->GetTeamID() != INVALID_ID )
    {//被邀请人已经有队伍
        WGTeamError Msg;
        Msg.SetPlayerID( pSourUser->GetPlayerID() );
        Msg.SetGUID( pDestUser->GetGUID() );
        Msg.SetErrorCode(TEAM_ERROR_INVITEDESTHASTEAM);

        pSourServerPlayer->SendPacket( &Msg );

        if ( pLeader != NULL )
        {
            Msg.SetPlayerID( pLeader->GetPlayerID() );
            pLeaderServerPlayer->SendPacket( &Msg );
        }

        Log::SaveLog( WORLD_LOGFILE, "GWTeamRetInviteHandler...DestInTeam SourGUID=%X DestGUID=%X", 
            sGuid, dGuid );
    }
    else if( pSourUser->GetTeamID()==INVALID_ID )
    {//邀请人和被邀请人都无队伍
        TeamID_t tid = g_pTeamList->CreateTeam( );
        Assert( tid!=INVALID_ID );
        Team* pTeam = g_pTeamList->GetTeam( tid );
        Assert( pTeam );

        if ( pSourUser->GetGUID() == pDestUser->GetGUID() )
        {

            //将玩家加入队伍中
            TEAMMEMBER Member;
            Member.m_Member = sGuid;
            pTeam->AddMember( &Member );

            //设置玩家队伍数据
            pSourUser->SetTeamID( tid );

            //返回结果
            WGTeamResult Msg;
            Msg.SetPlayerID( pSourUser->GetPlayerID() );
            Msg.SetReturn( TEAM_RESULT_MEMBERENTERTEAM );
            Msg.SetGUID( sGuid );
            Msg.SetTeamID( tid );
            Msg.SetGUIDEx( pSourUser->GetPlayerID() ); // 将玩家的 PlayerID 传回
            Msg.SetIcon( pSourUser->GetPortrait() );
            Msg.SetSceneID( pSourUser->GetSceneID() );
            Msg.SetDataID( pSourUser->GetSex() );


            pSourServerPlayer->SendPacket( &Msg );

            Log::SaveLog( WORLD_LOGFILE, "GWTeamRetInviteHandler...CreateTeam GUID=%X TeamID=%d", 
                sGuid, tid );
        }
        else
        {
            //将玩家加入队伍中
            TEAMMEMBER sMember;
            sMember.m_Member = sGuid;
            pTeam->AddMember( &sMember );
            TEAMMEMBER dMember;
            dMember.m_Member = dGuid;
            pTeam->AddMember( &dMember );

            //设置玩家队伍数据
            pSourUser->SetTeamID( tid );
            pDestUser->SetTeamID( tid );

            //返回结果
            WGTeamResult sMsg1;
            sMsg1.SetPlayerID( pSourUser->GetPlayerID() );
            sMsg1.SetReturn( TEAM_RESULT_TEAMREFRESH );
            sMsg1.SetGUID( sGuid );
            sMsg1.SetTeamID( tid );
            sMsg1.SetGUIDEx( pSourUser->GetPlayerID() ); // 将玩家的 PlayerID 传回
            sMsg1.SetSceneID( pSourUser->GetSceneID() );
            pSourServerPlayer->SendPacket( &sMsg1 );

            WGTeamResult sMsg2;
            sMsg2.SetPlayerID( pSourUser->GetPlayerID() );
            sMsg2.SetReturn( TEAM_RESULT_MEMBERENTERTEAM );
            sMsg2.SetGUID( dGuid );
            sMsg2.SetTeamID( tid );
            sMsg2.SetGUIDEx( pDestUser->GetPlayerID() ); // 将玩家的 PlayerID 传回
            sMsg2.SetSceneID( pDestUser->GetSceneID() );
            sMsg2.SetName( pDestUser->GetName() );
            sMsg2.SetIcon( pDestUser->GetPortrait() );
            sMsg2.SetDataID( pDestUser->GetSex() );
            pSourServerPlayer->SendPacket( &sMsg2 );

            WGTeamResult dMsg1;
            dMsg1.SetPlayerID( pDestUser->GetPlayerID() );
            dMsg1.SetReturn( TEAM_RESULT_TEAMREFRESH );
            dMsg1.SetGUID( sGuid );
            dMsg1.SetTeamID( tid );
            dMsg1.SetGUIDEx( pSourUser->GetPlayerID() ); // 将玩家的 PlayerID 传回
            dMsg1.SetSceneID( pSourUser->GetSceneID() );
            dMsg1.SetName( pSourUser->GetName() );
            dMsg1.SetIcon( pSourUser->GetPortrait() );
            dMsg1.SetDataID( pSourUser->GetSex() );
            pDestServerPlayer->SendPacket( &dMsg1 );

            WGTeamResult dMsg2;
            dMsg2.SetPlayerID( pDestUser->GetPlayerID() );
            dMsg2.SetReturn( TEAM_RESULT_MEMBERENTERTEAM );
            dMsg2.SetGUID( dGuid );
            dMsg2.SetTeamID( tid );
            dMsg2.SetGUIDEx( pDestUser->GetPlayerID() ); // 将玩家的 PlayerID 传回
            dMsg2.SetSceneID( pDestUser->GetSceneID() );
            pDestServerPlayer->SendPacket( &dMsg2 );

            Log::SaveLog( WORLD_LOGFILE, "GWTeamRetInviteHandler...CreateTeam sGUID=%X dGUID=%X TeamID=%d", 
                sGuid, dGuid, tid );
        }

    }
    else
    {//邀请人有队伍, 被邀请人无队伍
        TeamID_t tid = pSourUser->GetTeamID();
        Team* pTeam = g_pTeamList->GetTeam( tid );
        Assert( pTeam );
        if( pTeam->IsFull() )
        {//队伍人数已经满了
            WGTeamError sMsg;
            sMsg.SetPlayerID( pSourUser->GetPlayerID() );
            sMsg.SetGUID( pDestUser->GetGUID() );
            sMsg.SetErrorCode( TEAM_ERROR_INVITETEAMFULL );
            pSourServerPlayer->SendPacket( &sMsg );

            WGTeamError dMsg;
            dMsg.SetPlayerID( pDestUser->GetPlayerID() );
            dMsg.SetGUID( pDestUser->GetGUID() );
            dMsg.SetErrorCode( TEAM_ERROR_APPLYTEAMFULL );
            pDestServerPlayer->SendPacket( &dMsg );
    
            Log::SaveLog( WORLD_LOGFILE, "GWTeamRetInviteHandler...Team Full sGUID=%X dGUID=%X TeamID=%d", 
                sGuid, dGuid, tid );
        }
        else
        { //将玩家加入队伍
            TEAMMEMBER Member;
            Member.m_Member = dGuid;
            pTeam->AddMember( &Member );

            //设置玩家队伍信息
            pDestUser->SetTeamID( pTeam->GetTeamID() );
            WGTeamResult Msg1; // 发给新队员的
            Msg1.SetPlayerID( pDestUser->GetPlayerID() );
            Msg1.SetTeamID( tid );
            WGTeamResult Msg2; // 发给每个队员的
            Msg2.SetReturn( TEAM_RESULT_MEMBERENTERTEAM );
            Msg2.SetTeamID( tid );
            Msg2.SetGUID( dGuid );
            Msg2.SetGUIDEx( pDestUser->GetPlayerID() ); // 将玩家的 PlayerID 传回
            Msg2.SetSceneID( pDestUser->GetSceneID() );
            Msg2.SetName( pDestUser->GetName() );
            Msg2.SetIcon( pDestUser->GetPortrait() );
            Msg2.SetDataID( pDestUser->GetSex() );

            //通知所有组内的玩家
            for( int i=0; i<pTeam->MemberCount(); i++ )
            {
                TEAMMEMBER* pMember = pTeam->Member( i );
                if( pMember==NULL )
                {
                    Assert(FALSE);
                    continue;
                }

                USER* pUser = g_pOnlineUser->FindUser( pMember->m_Member );
                if( pUser==NULL )
                {//如果队员离线,则用户数据是空
                    continue;
                }
                
                ID_t ServerID = pUser->GetServerID();
                ServerPlayer* pServerPlayer = g_pServerManager->GetServerPlayer( ServerID );
                if( pServerPlayer==NULL )
                {
                    Assert(FALSE);
                    continue;
                }

                Msg2.SetPlayerID( pUser->GetPlayerID() );
                pServerPlayer->SendPacket( &Msg2 );

                if( pMember->m_Member != dGuid )
                { // 将自己以外的玩家传给新玩家
                    Msg1.SetReturn( TEAM_RESULT_TEAMREFRESH );
                    Msg1.SetName( pUser->GetName() );
                    Msg1.SetIcon( pUser->GetPortrait() );
                    Msg1.SetDataID( pUser->GetSex() );

                    Msg1.SetGUID( pMember->m_Member );
                    Msg1.SetGUIDEx( pUser->GetPlayerID() ); // 将玩家的 PlayerID 传回
                    Msg1.SetSceneID( pUser->GetSceneID() );

                    pDestServerPlayer->SendPacket( &Msg1 );
                }

            }

            Log::SaveLog( WORLD_LOGFILE, "GWTeamRetInviteHandler...Success! sGUID=%X dGUID=%X TeamID=%d", 
                sGuid, dGuid, tid );
        }
    }

    return PACKET_EXE_CONTINUE;

__LEAVE_FUNCTION

    return PACKET_EXE_ERROR;
}
uint GWTeamInviteHandler::Execute( GWTeamInvite* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION

	ServerPlayer* pSourServerPlayer = (ServerPlayer*)pPlayer;

	GUID_t sGuid = pPacket->GetSourGUID();

	USER* pSourUser = g_pOnlineUser->FindUser( sGuid );
	if( pSourUser==NULL )
	{
		Log::SaveLog( WORLD_LOGFILE, "GWTeamInviteHandler...User Sour GUID=%X not find!", 
			sGuid );

		return PACKET_EXE_CONTINUE;
	}

	USER* pDestUser = g_pOnlineUser->FindUser( pPacket->GetDestName() );
	if( pDestUser==NULL )
	{
		Log::SaveLog( WORLD_LOGFILE, "GWTeamInviteHandler...User Dest Name=%s not find!", 
			pPacket->GetDestName() );

		return PACKET_EXE_CONTINUE;
	}

	GUID_t dGuid = pDestUser->GetGUID();

	if( pSourUser->IsEnemy( pDestUser->GetUserCampData() ) )
	{
		Log::SaveLog( WORLD_LOGFILE, "GWTeamInviteHandler...Sour Name=%s, Dest Name=%s are enemy!", 
			pSourUser->GetName(), pDestUser->GetName() );

		return PACKET_EXE_CONTINUE;
	}

	// 设置了拒绝被邀请
	if( pDestUser->IsRefuseTeamInvite() )
	{
		WGTeamError Msg;
		Msg.SetPlayerID( pSourUser->GetPlayerID() );
		Msg.SetGUID(sGuid);
		Msg.SetErrorCode(TEAM_ERROR_REFUSEINVITESETTING);
		pSourServerPlayer->SendPacket( &Msg );

		Log::SaveLog( WORLD_LOGFILE, "GWTeamInviteHandler...DestGUID=%X refuse to be invited. ", 
			dGuid );
		return PACKET_EXE_CONTINUE;
	}

	if( pDestUser->GetTeamID() != INVALID_ID )
	{//被邀请人已经属于某个队伍了
		WGTeamError Msg;
		Msg.SetPlayerID( pSourUser->GetPlayerID() );
		Msg.SetGUID(sGuid);
		Msg.SetErrorCode(TEAM_ERROR_INVITEDESTHASTEAM);
		pSourServerPlayer->SendPacket( &Msg );

		Log::SaveLog( WORLD_LOGFILE, "GWTeamInviteHandler...DestInTeam SourGUID=%X DestGUID=%X", 
			sGuid, dGuid );
	}
	else if( sGuid==dGuid && pSourUser->GetTeamID()==INVALID_ID )
	{//邀请人和被邀请人属于同一个人, 且不属于某个队伍
		//自建队伍
		TeamID_t tid = g_pTeamList->CreateTeam( );
		Assert( tid!=INVALID_ID );
		Team* pTeam = g_pTeamList->GetTeam( tid );
		Assert( pTeam );

		//将玩家加入队伍中
		TEAMMEMBER Member;
		Member.m_Member = sGuid;
		pTeam->AddMember( &Member );

		//设置玩家队伍数据
		pSourUser->SetTeamID( tid );

		//返回结果
		WGTeamResult Msg;
		Msg.SetPlayerID( pSourUser->GetPlayerID() );
		Msg.SetReturn( TEAM_RESULT_MEMBERENTERTEAM );
		Msg.SetGUID( sGuid );
		Msg.SetTeamID( tid );
		Msg.SetGUIDEx( pSourUser->GetPlayerID() ); // 将玩家的 PlayerID 传回
		Msg.SetSceneID( pSourUser->GetSceneID() );
		Msg.SetDataID( pSourUser->GetSex() );
		Msg.SetIcon( pSourUser->GetPortrait() );

		pSourServerPlayer->SendPacket( &Msg );

		Log::SaveLog( WORLD_LOGFILE, "GWTeamInviteHandler...CreateTeam GUID=%X TeamID=%d", 
			sGuid, tid );
	}
	else
	{
		if ( pSourUser->GetTeamID() != INVALID_ID )
		{
			//邀请人已经有一个队伍
			Team* pTeam = g_pTeamList->GetTeam( pSourUser->GetTeamID() );
			Assert( pTeam );

			GUID_t tlGUID = pTeam->Leader()->m_Member; // 队长GUID

			//邀请人不是队长,要给队长发送请求
			if ( tlGUID != sGuid )
			{ // 不是队长的情况
				USER* pLeaderUser = g_pOnlineUser->FindUser( tlGUID );
				if( pLeaderUser == NULL )
				{
					Assert(FALSE);
				}

				ID_t LeaderServerID = pLeaderUser->GetServerID();
				ServerPlayer* pLeaderServerPlayer = g_pServerManager->GetServerPlayer( LeaderServerID );
				if( pLeaderServerPlayer==NULL )
				{
					Assert(FALSE);
				}

				WGTeamLeaderAskInvite Msg;
				Msg.SetPlayerID( pLeaderUser->GetPlayerID() );//队长的Player_t
				Msg.SetSourGUID( sGuid );		//邀请人
				Msg.SetDestGUID( dGuid );		//被要请人
				Msg.SetSourName( pSourUser->GetName() );
				Msg.SetDestName( pDestUser->GetName() );
				Msg.SetGUID(tlGUID);

				pLeaderServerPlayer->SendPacket( &Msg );

				Log::SaveLog( WORLD_LOGFILE, "GWTeamInviteHandler...TeamLeaderAskInvite SourGUID=%X DestGUID=%X", 
					sGuid, dGuid );
				return PACKET_EXE_CONTINUE;
			}
		}

		ID_t DestServerID = pDestUser->GetServerID();
		ServerPlayer* pDestServerPlayer = g_pServerManager->GetServerPlayer( DestServerID );
		if( pDestServerPlayer )
		{//向被邀请人发送邀请消息
			WGTeamAskInvite Msg;
			Msg.SetPlayerID( pDestUser->GetPlayerID() );
			Msg.SetdGUID( dGuid );
			Msg.SetsGUID( sGuid );

			if ( pSourUser->GetTeamID() != INVALID_ID )
			{
				Team* pTeam = g_pTeamList->GetTeam( pSourUser->GetTeamID() );
				Assert( pTeam );

			//	Msg.SetMemberCount( pTeam->MemberCount() );

				for( INT i=0; i<pTeam->MemberCount(); ++i )
				{
					WGTeamAskInvite::InviterInfo info;
					TEAMMEMBER* pMember = pTeam->Member( i );
					if( pMember == NULL )
					{
						Assert(FALSE);
						continue ;
					}

					USER* pUser = g_pOnlineUser->FindUser( pMember->m_Member );
					if( pUser == NULL )
					{//如果队员离线,则用户数据是空
						continue ;
					}

					info.m_PlayerID = pUser->GetPlayerID();
					info.m_NickSize = (UCHAR)strlen(pUser->GetName());
					strncpy( (CHAR*)info.m_szNick, pUser->GetName(), info.m_NickSize );
					info.m_uFamily = pUser->GetMenpai();
					info.m_Scene = pUser->GetSceneID();
					info.m_Level = pUser->GetLevel();
					info.m_uDataID = pUser->GetSex();

					Msg.AddInviterInfo( info );
				}
			}
			else
			{
			//	Msg.SetMemberCount( 1 );
				WGTeamAskInvite::InviterInfo info;
				info.m_PlayerID = pSourUser->GetPlayerID();
				info.m_NickSize = (UCHAR)strlen(pSourUser->GetName());
				strncpy( (CHAR*)info.m_szNick, pSourUser->GetName(), info.m_NickSize );
				info.m_uFamily = pSourUser->GetMenpai();
				info.m_Scene = pSourUser->GetSceneID();
				info.m_Level = pSourUser->GetLevel();
				info.m_uDataID = pSourUser->GetSex();

				Msg.AddInviterInfo( info );
			}

			pDestServerPlayer->SendPacket( &Msg );
		}
		else
		{
			Assert(FALSE);
		}

		Log::SaveLog( WORLD_LOGFILE, "GWTeamInviteHandler...AskInvite SourGUID=%X DestGUID=%X", 
			sGuid, dGuid );

	}


	return PACKET_EXE_CONTINUE;

__LEAVE_FUNCTION

	return PACKET_EXE_ERROR;
}