uint	GWDetailOtherOnlineAttrib_HorseHandler::Execute(GWDetailOtherOnlineAttrib_Horse* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION

	ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer;
	Assert( pServerPlayer );

	GUID_t guid = pPacket->GetPlayerGUID();
	USER* pUser = g_pOnlineUser->FindUser(guid);
	if(pUser){
		ID_t ServerID = pUser->GetServerID() ;
		ServerPlayer* pDestServerPlayer = g_pServerManager->GetServerPlayer( ServerID ) ;
		if( pDestServerPlayer==NULL )
		{
			Assert(FALSE);
		}
		WGDetailOtherOnlineAttrib_Horse Msg;
		Msg.SetPlayerID(pPacket->GetPlayerID());//发起查看者的ID

		Msg.SetGUID(pPacket->GetGUID());
		Msg.SetDataID(pPacket->GetDataID());
		Msg.SetLevel(pPacket->GetLevel());
		Msg.SetGenGu(pPacket->GetGenGu());
		Msg.SetRemainPoint(pPacket->GetRemainPoint());
		Msg.SetExp(pPacket->GetExp());
		Msg.SetGeneration(pPacket->GetGeneration());
		Msg.SetHappiness(pPacket->GetHappiness());
		Msg.SetSpouseGUID(pPacket->GetSpouseGUID());
		Msg.SetName(pPacket->GetName());
		Msg.SetNickName(pPacket->GetNickName());
		Msg.SetDexPerception(pPacket->GetDexPerception());
		Msg.SetStrPerception(pPacket->GetStrPerception());
		Msg.SetIntPerception(pPacket->GetIntPerception());
		Msg.SetConPerception(pPacket->GetConPerception());
		Msg.SetSavvy(pPacket->GetSavvy());
		Msg.SetMountID(pPacket->GetMountID());

		Msg.SetHorseState(pPacket->GetHorseState());
		Msg.SetGrowRate(pPacket->GetGrowRate());

		for(UINT i=0; i<PET_MAX_SKILL_COUNT; ++i){
			Msg.SetSkill(i, pPacket->GetSkill(i));
		}

		Msg.SetCon(pPacket->GetCon());
		Msg.SetDex(pPacket->GetDex());
		Msg.SetInt(pPacket->GetInt());
		Msg.SetStr(pPacket->GetStr());

		pDestServerPlayer->SendPacket(&Msg);

		Log::SaveLog( WORLD_LOGFILE, "GWDetailOtherOnlineAttrib_HorseHandler: ok ");
	}

	return PACKET_EXE_CONTINUE;

__LEAVE_FUNCTION

	return PACKET_EXE_ERROR;
}
UINT GWCityCloseSuccessHandler::Execute( GWCityCloseSuccess* pPacket, Player* pPlayer )
{
    __ENTER_FUNCTION

        ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer;
        _CITY_GUID    CityGuid = pPacket->GetCityGuid();

        City* pDelCity = g_pCityManager->GetCityByGuid(CityGuid);
        if(!pDelCity->IsLock())
        {//已经有人在删除此城市了
            Assert(FALSE);
            return PACKET_EXE_CONTINUE ;
        }

        SceneID_t CitySceneID = pDelCity->GetSceneID();

        GUID_t PlayerGuid = pDelCity->GetApplicantGuid();
        g_pCityManager->DelCityByGuid(CityGuid);

        WGCityCloseSuccess MsgToServer;
        MsgToServer.SetPlayerGuid(PlayerGuid);
        MsgToServer.SetSceneID(CitySceneID);
        pServerPlayer->SendPacket(&MsgToServer);
        
        return PACKET_EXE_CONTINUE ;

    __LEAVE_FUNCTION

        return PACKET_EXE_ERROR ;
}
UINT GWCallOfHumanHandler::Execute( GWCallOfHuman* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION

    USER* pUser = g_pOnlineUser->FindUser( pPacket->GetCallOfTargetGUID() ) ;
    if( pUser==NULL )
    {
        Assert(FALSE) ;
        return PACKET_EXE_CONTINUE ;
    }

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

    WGCallOfHuman msgCallOfHuman;
    msgCallOfHuman.SetCallOfTargetPlayerID(pUser->GetPlayerID());
    msgCallOfHuman.SetCallOfInfo(pPacket->GetCallOfInfo());
    msgCallOfHuman.SetGUID(pPacket->GetCallOfTargetGUID());
    pServerPlayer->SendPacket(&msgCallOfHuman);

    Log::SaveLog( WORLD_LOGFILE, "GWCallOfHumanHandler" );

    return PACKET_EXE_CONTINUE ;

__LEAVE_FUNCTION

    return PACKET_EXE_ERROR ;
}
Exemple #4
0
uint GWHeartBeatHandler::Execute( GWHeartBeat* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION

	ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer ;

	GUID_t sGUID = pPacket->GetGUID() ;

	USER* pUser = g_pOnlineUser->FindUser( sGUID ) ;
	if( pUser==NULL )
	{
		WGNotifyUser Msg ;
		Msg.SetGUID( sGUID ) ;
		Msg.SetStatus( WGNotifyUser::NUS_REMOVE ) ;

		pServerPlayer->SendPacket( &Msg ) ;
		
		Log::SaveLog( WORLD_LOGFILE, "GWHeartBeatHandler...User GUID=%X not find! Notify server!", 
			sGUID ) ;

		return PACKET_EXE_CONTINUE ;
	}

	pUser->ResetKickTime() ;

	Log::SaveLog( WORLD_LOGFILE, "GWHeartBeatHandler...User GUID=%X Status=%d!", 
		sGUID, pUser->UserStatus() ) ;
	
	return PACKET_EXE_CONTINUE ;

	__LEAVE_FUNCTION

		return PACKET_EXE_ERROR ;
}
Exemple #5
0
// 给该玩家发送某好友下线的信息
VOID USER::SendRelationOfflineMsg(USER* pUser)
{
__ENTER_FUNCTION

    Assert( pUser );

    if( UserStatus() != US_NORMAL )
    {
        return;
    }

    ServerPlayer* pServerPlayer = g_pServerManager->GetServerPlayer( GetServerID() );
    if( pServerPlayer == NULL )
    {
        Assert( pServerPlayer );
        return;
    }

    WGRelation Msg;

    WG_RELATION* pRelation = Msg.GetRelation();

    pRelation->SetPlayerID( GetPlayerID() );
    pRelation->m_Type = RET_RELATIONOFFLINE;
    pRelation->m_RelationGUID.SetTargetGUID( pUser->GetGUID() );

    pServerPlayer->SendPacket( &Msg );

__LEAVE_FUNCTION
}
Exemple #6
0
UINT LWChangeNameHandler::Execute(LWChangeName* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION
	
	TID CurrentThreadID = MyGetCurrentThreadID();

	if(CurrentThreadID == g_pServerManager->m_ThreadID)
	{

		Assert(pPacket);
		
		ServerPlayer* pServerPlayer  = (ServerPlayer*)pPlayer;
		
		Assert(pServerPlayer);

		pServerPlayer->SendPacket(pPacket);
	}
	else
	{
		AssertEx(FALSE,"LWChangeNameHandler 线程资源执行错误!");
	}
	g_pLog->FastSaveLog(LOG_FILE_0,"LWChangeNameHandler::Execute() ....OK");

	return PACKET_EXE_CONTINUE;

__LEAVE_FUNCTION

	return PACKET_EXE_ERROR;
}
UINT CLAskLoginHandler::Execute( CLAskLogin* pPacket, Player* pPlayer)
{
	printf("#CLAskLoginHandler-------------account:%s,password:%s,version:%u",pPacket->GetAccount(),pPacket->GetPassWord(),pPacket->GetVersion());

	GatewayPlayer* pGatewayPlayer = static_cast<GatewayPlayer*>(pPlayer);
	Assert(pGatewayPlayer);

	/*if(pGatewayPlayer->GetPlayerStatus() != PS_LOGIN_STATUS)
	{
		return PACKET_EXE_ERROR;
	}
	*/

	ServerPlayer*	pServerPlayer = g_pServerManager->GetServerPlayer(SCENE_PLAYER_ID);
	if(pServerPlayer==NULL)
	{
		Assert(false);
		return PACKET_EXE_CONTINUE;
	}

	imxGSConnect msg;
	msg.SetAccount(pPacket->GetAccount());
	msg.SetPlayerID(pPlayer->PlayerID());
	pServerPlayer->SendPacket(&msg);

	/*LCRetLogin msg1;
	msg1.SetAccount(pPacket->GetAccount());
	msg1.SetResult(LOGINR_SUCCESS);
	pGatewayPlayer->SendPacket(&msg1);*/

	return PACKET_EXE_CONTINUE;
}
UINT    LBAskAuthHandler::Execute(LBAskAuth* pPacket, Player* pPlayer )
{
    __ENTER_FUNCTION
        
        TID CurrentThreadID = MyGetCurrentThreadID();
        
        if(CurrentThreadID == g_pServerManager->m_ThreadID)
        {
            Assert(pPacket);

            ServerPlayer* pServerPlayer  = (ServerPlayer*)pPlayer;

            Assert(pServerPlayer);

            pServerPlayer->SendPacket(pPacket);
        }
        else
        {
            AssertEx(FALSE,"LBAskAuthHandler 线程资源执行错误!");
        }
        
        Log::SaveLog(LOGIN_LOGFILE,"LBAskAuthHandler::Execute() ....OK");

        return PACKET_EXE_CONTINUE;

    __LEAVE_FUNCTION

        return PACKET_EXE_ERROR;
}
UINT LWAskDeleteCharHandler::Execute(LWAskDeleteChar* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION
	
	Assert(pPacket);
	
	ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer ;
	Assert(pServerPlayer);

	WLRetDeleteChar Msg;
	Msg.SetAccount( pPacket->GetAccount() );
	Msg.SetPlayerGUID( pPacket->GetPlayerGUID() );
	Msg.SetPlayerID( pPacket->GetPlayerID() );

	USER* pUser = g_pOnlineUser->FindUser( pPacket->GetPlayerGUID() );
	if( pUser )
	{
		Msg.SetResult( ASKDELETECHAR_ONLINE );
		Log::SaveLog( WORLD_LOGFILE, "LWAskDeleteCharHandler...Cannot Delete User, CharGUID = %X",pPacket->GetPlayerGUID()) ;
	}
	else
	{
		Msg.SetResult( ASKDELETECHAR_SUCCESS );
		Log::SaveLog( WORLD_LOGFILE, "LWAskDeleteCharHandler...Can Delete User, CharGUID = %X",pPacket->GetPlayerGUID()) ;
	}

	pServerPlayer->SendPacket(&Msg);


	return PACKET_EXE_CONTINUE;

	__LEAVE_FUNCTION

	return PACKET_EXE_ERROR;
}
Exemple #10
0
uint	GWQueryHorseFindMateInfoHandler::Execute(GWQueryHorseFindMateInfo* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION

	ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer;
	Assert( pServerPlayer );

	BOOL bContinue = FALSE;
	INT iReturnPos = 0;

	//////////////////////////////////////////////////////////////////////////
	// Allocates memory on the stack for Output
	//_alloca(uSize),放弃使用_alloca,该api在linux下强烈建议不要使用,另外在windows下还要进行SEH处理
	UINT uSize = (UINT)(sizeof(HorseFindMateInfo)*HorseFindMateInfoPerPage::MAX_COUNT_PER_PAGE);
	Assert(uSize < 1024);
	CHAR szAlloc[1024] = {0};

	HorseFindMateInfoTable::HorseFindMateInfoVector Output(
		HorseFindMateInfoPerPage::MAX_COUNT_PER_PAGE,
		(VOID*)(szAlloc)
		);

	if(HorseFindMateInfoManager::GetInstance().QueryHorseFindMateInfo(pPacket->GetPlayerGUID(), 
		pPacket->GetMaxPostion(), iReturnPos, Output, bContinue) ){

		WGReturnHorseFindMateInfo packet;

		HorseFindMateInfoPerPage result;
		result.m_iCount = Output.GetSize();

		Assert(result.m_iCount <= HorseFindMateInfoPerPage::MAX_COUNT_PER_PAGE);

		for(INT i=0; i<result.m_iCount; ++i){
			result.m_aList[i] = Output[i];
		}

		packet.SetSearch(FALSE);
		packet.SetReturnPostion(iReturnPos);
		packet.SetContinue(bContinue);
		packet.SetHorseFindMateResult(result);
		packet.SetPlayerID(pPacket->GetPlayerID());
		pServerPlayer->SendPacket(&packet);

	}

	return PACKET_EXE_CONTINUE;

__LEAVE_FUNCTION

	return PACKET_EXE_ERROR;
}
Exemple #11
0
uint GWCityApplyNewCityHandler::Execute( GWCityApplyNewCity* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION

		ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer;
		//入口场景ID
		SceneID_t	PortSceneID		=	pPacket->GetSceneID();
		//申请人GUID
		GUID_t		ApplicantGuid	=	pPacket->GetPlayerGuid();

		WGCityError MsgError;

		USER* pUser = g_pOnlineUser->FindUser( ApplicantGuid ) ;
		if( pUser==NULL )
		{
			Log::SaveLog( WORLD_LOGFILE, "GWCityApplyNewCityHandler...User GUID=%X not find!", 
				ApplicantGuid ) ;

			return PACKET_EXE_CONTINUE ;
		}

		//这里要判定当前任务是否有权利建立城市,当前工会是否有资格申请城市
		GuildID_t guildID = pUser->GetGuildID();
		Guild* pGuild = g_pGuildManager->GetGuild( guildID );

		//if(!pGuild)
		//{
		//	Log::SaveLog( WORLD_LOGFILE, "GWCityApplyNewCityHandler...User Guild not find! guildID = %d", 
		//		guildID ) ;
		//	return PACKET_EXE_CONTINUE ;
		//}

		//合法
		//通知Server去load城市场景,返回城市场景号
		WGCityApplyNewCity MsgToServer;
		MsgToServer.SetSceneID(PortSceneID);
		MsgToServer.SetPlayerGuid(ApplicantGuid);
		pServerPlayer->SendPacket( &MsgToServer );

		Log::SaveLog( WORLD_LOGFILE, "GWCityApplyNewCityHandler...User GUID=%X Finished", 
			ApplicantGuid ) ;

		return PACKET_EXE_CONTINUE ;

	__LEAVE_FUNCTION

		return PACKET_EXE_ERROR ;
}
Exemple #12
0
uint GWCityCloseHandler::Execute( GWCityClose* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION

		ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer;

		_CITY_GUID	  CityGuid		= pPacket->GetCityGuid();
		GUID_t		  PlayerGuid	= pPacket->GetPlayerGuid();
		WGCityError MsgError;

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

		City* pDelCity = g_pCityManager->GetCityByGuid(CityGuid);
		if(!pDelCity)
		{
			Log::SaveLog( WORLD_LOGFILE, "GWCityCloseHandler...User GUID world=%d poolpos=%d  not find!", 
				CityGuid.m_World, CityGuid.m_PoolPos) ;
			return PACKET_EXE_CONTINUE ;
		}

		if(pDelCity->IsLock())
		{//已经有人删除此城市了
			Log::SaveLog( WORLD_LOGFILE, "GWCityCloseHandler...User GUID world=%d poolpos=%d  not find!", 
				CityGuid.m_World, CityGuid.m_PoolPos) ;
			return PACKET_EXE_CONTINUE ;
		}
		
		pDelCity->SetApplicantGuid(PlayerGuid);
		pDelCity->SetLock(TRUE);
		
		WGCityClose MsgToServer;
		MsgToServer.SetSceneID(pDelCity->GetSceneID());
		MsgToServer.SetPlayerID(pUser->GetPlayerID());
		pServerPlayer->SendPacket(&MsgToServer);
		
		return PACKET_EXE_CONTINUE ;

	__LEAVE_FUNCTION

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

    ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer;
    GUID_t guid = pPacket->GetGUID(); // 被请求信息的玩家的 GUID
    WGTeamMemberInfo Msg;

    Msg.SetPlayerID( pPacket->GetObjID() );
    Msg.SetGUID( guid );

    USER* pUser = g_pOnlineUser->FindUser( guid );
    if( pUser == NULL )
    {   // 离线状态
        Log::SaveLog( WORLD_LOGFILE, "GWAskTeamInfoHandler...User GUID=%X not find!", guid );
        return PACKET_EXE_CONTINUE;
    }

    Msg.SetFamily( pUser->GetMenpai() );
    Msg.SetLevel( pUser->GetLevel() );

    if( pUser->UserStatus() != US_NORMAL )
    {
        Msg.SetDeadLinkFlag( TRUE );
    }
    else
    {
        Msg.SetDeadLinkFlag( FALSE );
    }

    pServerPlayer->SendPacket( &Msg );
    Log::SaveLog( WORLD_LOGFILE, "GWAskTeamInfoHandler...User GUID=%X was find!", guid );

    return PACKET_EXE_CONTINUE;

    __LEAVE_FUNCTION

    return PACKET_EXE_ERROR;
}
Exemple #14
0
UINT BLRetBillingKeepHandler::Execute(BLRetBillingKeep* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION
		
	Assert(pPlayer);
	if(pPlayer->IsBillingPlayer())
	{
		BillingPlayer* pBillPlayer = static_cast<BillingPlayer*>(pPlayer);

		Assert(pBillPlayer);
		Assert(pPacket);

		LWRetBillingKeep	Msg;

		Msg.SetAccount(pPacket->GetAccount());
		Msg.SetResult(pPacket->GetResult());
		Msg.SetLeftTime(pPacket->GetTimeLeft());
		Msg.SetStorePoint(pPacket->GetStorePoint());
		Msg.SetUserPoint(pPacket->GetUserPoint());

		ServerPlayer* pServerPlayer =	
			static_cast<ServerPlayer*>(g_pServerManager->GetServerPlayer(WORLD_PLAYER_ID));
		if(pServerPlayer)
		{
			pServerPlayer->SendPacket(&Msg);
		}

		
		g_pLog->FastSaveLog(LOG_FILE_0,"BLRetBillingKeep::Execute()...Acc=%s BillingKeep Result = %d,lt=%d,sp=%d,up=%d",
		pPacket->GetAccount(),pPacket->GetResult(),pPacket->GetTimeLeft(),pPacket->GetStorePoint(),pPacket->GetUserPoint());
	}


		return PACKET_EXE_CONTINUE;

	__LEAVE_FUNCTION

		return PACKET_EXE_ERROR;
}
Exemple #15
0
UINT GWCountryFetchHandler::Execute( GWCountryFetch* pPacket, Player* pPlayer )
{
    __ENTER_FUNCTION

    ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer;
    GUID_t guid = pPacket->GetGuid();

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


    INT nCountry = pUser->GetCountry();
    _COUNTRY *pCountry = g_pCountryManager->GetCountryInfo(nCountry);

    if (pCountry)
    {
        pCountry->SubGold(pPacket->GetGold());
        Log::SaveLog( WORLD_LOGFILE, "GWCountryFetchHandler...User GUID=%X FetchGold = %d", 
            guid, pPacket->GetGold());

        WGCountryFetch Msg;
        Msg.SetPlayerID( pUser->GetPlayerID() );
        Msg.SetGold( pPacket->GetGold() );

        pServerPlayer->SendPacket( &Msg );
    }

    return PACKET_EXE_CONTINUE ;

    __LEAVE_FUNCTION

        return PACKET_EXE_ERROR ;
}
UINT GWCountryInfoRequestHandler::Execute( GWCountryInfoRequest* pPacket, Player* pPlayer )
{
    __ENTER_FUNCTION

    ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer;
    GUID_t guid = pPacket->GetGuid();

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

    _COUNTRY country;
    g_pCountryManager->GetCountryInfo(pUser->GetCountry(), country);   

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

    COUNTRY_CGW_COUNTRY_INFO info;
    info.m_CountryID    =   pUser->GetCountry();
    memcpy(&info.m_CountryInfo, &country, sizeof(_COUNTRY));
    Msg.SetCountryInfo( &info );
    pServerPlayer->SendPacket( &Msg );

    Log::SaveLog( WORLD_LOGFILE, "GWCountryInfoRequestHandler...User GUID=%X send CountryInfo!", 
        guid );

    return PACKET_EXE_CONTINUE ;

    __LEAVE_FUNCTION

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

	ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer ;

	USER* pUser = g_pOnlineUser->FindUser( pPacket->GetGUID() ) ;
	WGRetUserData Msg ;
	if( pUser==NULL )
	{//没有发现在“在线用户列表”里对应此GUID的用户
		
		Log::SaveLog( WORLD_LOGFILE, "GWAskUserDataHandler...User GUID=%X not find!", 
			pPacket->GetGUID() ) ;
		//如果是完整的Login 模式
		if( g_Config.m_WorldInfo.m_EnableShareMem )
		{
			Msg.SetPlayerID( pPacket->GetPlayerID() ) ;
			Msg.SetReturn( UDR_NOTFINDUSERDATA ) ;

			pServerPlayer->SendPacket( &Msg ) ;

			return PACKET_EXE_CONTINUE ;
		}

		//不是完整的login 模式
		//测试数据
		pUser = g_pOnlineUser->LoadUser( pPacket->GetGUID(), pPacket->GetCountry(), pPacket->GetProfession(),pPacket->GetAccount()) ;

		if( pUser )
		{
			_HUMAN_DB_LOAD* pDBHuman = &(pUser->GetFullUserData()->m_Human);

			pUser->SetTeamID( pUser->GetFullUserData()->m_Human.m_TeamID );

			//临时测试数据
			strncpy( pDBHuman->m_Name, pPacket->GetAccount(), MAX_CHARACTER_NAME-1 ) ;
			pDBHuman->m_Sex		= (BOOL)(pPacket->GetGender()) ;
			pDBHuman->m_nCountry = pPacket->GetCountry();
			pDBHuman->m_MenPai   = pPacket->GetProfession();
			pDBHuman->m_FaceModel = pPacket->GetFaceModel();
			pUser->SetKey( pPacket->GetKey() );
			//临时测试数据

			g_pOnlineUser->OnUserLogin( pUser ) ;
            g_pCountryManager->AddCountryUser((COUNTRY_ATTRIBUTE)pUser->GetCountry(), pUser->GetGUID());

			Msg.SetPlayerID( pPacket->GetPlayerID() ) ;
			Msg.SetReturn( UDR_USERDATA ) ;
			Msg.SetUserData( pUser->GetFullUserData() ) ;


			//回收数据块, 设置用户状态
			g_pOnlineUser->DelData( pUser->GetFullUserData() ) ; //modified by wuwenbin
			pUser->SetFullUserData( NULL );	//为什么置空,随后FindUser时造成FULLUSERDATA结构为空
			pUser->SetUserStatus( US_NORMAL );
			pUser->ResetKickTime();

			//将用户所在服务器的PlayerID记录到用户数据里
			pUser->SetPlayerID( pPacket->GetPlayerID() );

			pServerPlayer->SendPacket( &Msg ) ;

			Log::SaveLog( WORLD_LOGFILE, "GWAskUserDataHandler...Load GUID=%X OK!", 
				pPacket->GetGUID() ) ;
		}
		else
		{
			Log::SaveLog( WORLD_LOGFILE, "ERROR:GWAskUserDataHandler...Load GUID=%X false!", 
				pPacket->GetGUID() ) ;
		}
//测试数据
//

		return PACKET_EXE_CONTINUE ;
	}

	int iUserStatus = pUser->UserStatus() ;

	if( pUser->GetKey() != pPacket->GetKey() )
	{//验证码错误,警报,也许受到攻击
		Msg.SetPlayerID( pPacket->GetPlayerID() ) ;
		Msg.SetReturn( UDR_KEYERROR ) ;

		pServerPlayer->SendPacket( &Msg ) ;

		Log::SaveLog( WORLD_LOGFILE, "GWAskUserDataHandler.Key Error..User GUID=%X Status=%d", 
			pPacket->GetGUID(), iUserStatus ) ;

		return PACKET_EXE_CONTINUE ;
	}

	//将用户所在服务器的PlayerID记录到用户数据里
	pUser->SetPlayerID( pPacket->GetPlayerID() );

	switch( iUserStatus )
	{
	case US_NONE:
		{
			Msg.SetPlayerID( pPacket->GetPlayerID() ) ;
			Msg.SetReturn( UDR_NOTFINDUSERDATA ) ;

			pServerPlayer->SendPacket( &Msg ) ;
		}
		break ;
	case US_HOLDUSERDATA:
		{
			Msg.SetPlayerID( pPacket->GetPlayerID() ) ;
			Msg.SetReturn( UDR_USERDATA ) ;
			Msg.SetUserData( pUser->GetFullUserData() ) ;

			g_pOnlineUser->DelData( pUser->GetFullUserData() ) ;//回收数据块 // modified by wuwenbin
			pUser->SetFullUserData( NULL );	//为什么置空,随后FindUser时造成FULLUSERDATA结构为空
			pUser->SetUserStatus( US_NORMAL );
			pUser->ResetKickTime();

			pServerPlayer->SendPacket( &Msg ) ;
		}
		break ;
	case US_NORMAL:
	case US_OFFLINE:
		{
			Msg.SetPlayerID( pPacket->GetPlayerID() ) ;
			Msg.SetReturn( UDR_USERDATALIVING ) ;


			pUser->SetUserStatus( US_NORMAL );
			pUser->ResetKickTime();

			pServerPlayer->SendPacket( &Msg ) ;
		}
		break ;
	case US_CRASH_DOWN://取消对这种情况处理,由其他方式保证这种情况不会出现
		{
			Assert(FALSE);
			/*
			WGRetUserData Msg ;
			Msg.SetPlayerID( pPacket->GetPlayerID() ) ;
			Msg.SetReturn( UDR_USERSERVERCRASH ) ;
			pServerPlayer->SendPacket( &Msg ) ;
			*/
		}
		break;
	case US_WAIT_SHUTDOWN:
		{
			Msg.SetPlayerID( pPacket->GetPlayerID() ) ;
			Msg.SetReturn( UDR_USERSERVERCRASH ) ;
			pServerPlayer->SendPacket( &Msg ) ;
		}
		break ;
	default :
		{
			Assert(FALSE) ;
		}
		break ;
	};


	Log::SaveLog( WORLD_LOGFILE, "GWAskUserDataHandler...User GUID=%X Status=%d", 
		pPacket->GetGUID(), iUserStatus ) ;

	return PACKET_EXE_CONTINUE ;

__LEAVE_FUNCTION

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

	ServerPlayer* pSourServerPlayer = (ServerPlayer*)pPlayer;

	GUID_t sGuid = pPacket->GetSourGUID(); // 队长
	GUID_t dGuid = pPacket->GetDestGUID(); // 倒霉蛋

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

		return PACKET_EXE_CONTINUE;
	}

	TeamID_t tid = pSourUser->GetTeamID();
	Team* pTeam = g_pTeamList->GetTeam( tid );
	if( pTeam==NULL )
	{
		Log::SaveLog( WORLD_LOGFILE, "GWTeamKickHandler...User sGUID=%X TeamID=%d not find team!", 
			sGuid, tid );

		return PACKET_EXE_CONTINUE;
	}

	INT nMemberCount = pTeam->MemberCount();
	INT i;
	for( i=0; i<nMemberCount; ++i )
	{
		if ( pTeam->Member(i)->m_Member == dGuid )
		{
			break;
		}
	}

	if( i >= nMemberCount )
	{ // 被踢者不在队伍里
		Log::SaveLog( WORLD_LOGFILE, "GWTeamKickHandler...User dGUID=%X not in sTeamID=%d(sGUID=%X)!", 
			dGuid, tid, sGuid );

		return PACKET_EXE_CONTINUE;
	}

	if( pTeam->Leader()->m_Member != sGuid )
	{ // 踢人者不是队长
		WGTeamError Msg;
		Msg.SetPlayerID( pSourUser->GetPlayerID() );
		Msg.SetGUID( pSourUser->GetGUID() );
		Msg.SetErrorCode( TEAM_ERROR_KICKNOTLEADER );

		pSourServerPlayer->SendPacket( &Msg );

		Log::SaveLog( WORLD_LOGFILE, "GWTeamKickHandler...User sGUID=%X TeamID=%d not leader!", 
			sGuid, tid );

		return PACKET_EXE_CONTINUE;
	}

	WGTeamResult Msg;
	Msg.SetReturn( TEAM_RESULT_TEAMKICK );
	Msg.SetGUID( dGuid );
	Msg.SetTeamID( tid );

	//通知所有组内的玩家
	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 );
	}

	//剔除队员
	TEAMMEMBER Member;
	Member.m_Member = dGuid;
	pTeam->DelMember( &Member );

	//设置被踢者的队伍信息
	USER* pDestUser = g_pOnlineUser->FindUser( dGuid );
	if ( pDestUser!=NULL )
	{
		pDestUser->SetTeamID( INVALID_ID );
	}

	Log::SaveLog( WORLD_LOGFILE, "GWTeamKickHandler...User sGUID=%X TeamID=%d Success!", 
		sGuid, tid );

	return PACKET_EXE_CONTINUE;

__LEAVE_FUNCTION

	return PACKET_EXE_ERROR;
}
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 BLRetBillingStartHandler::Execute(BLRetBillingStart* pPacket, Player* pPlayer )
{
	__ENTER_FUNCTION

	Assert(pPlayer);

	if(pPlayer->IsBillingPlayer())
	{
		BillingPlayer* pBillPlayer = static_cast<BillingPlayer*>(pPlayer);

		Assert(pBillPlayer);
		Assert(pPacket);


		LWRetBillingStart	Msg;
		Msg.SetAccount(pPacket->GetAccount());
		Msg.SetResult(pPacket->GetResult());
		Msg.SetPlayerID(pPacket->GetPacketIndex());

		BYTE bResult =	pPacket->GetResult();		
		switch(bResult)
		{
		case 0x00:
			{
				Msg.SetCode(pPacket->GetCode());
				//计费不成功消息
				g_pLog->FastSaveLog(LOG_FILE_0,"BLRetBillingStart::Execute()...Acc=%s Billing Fail Code = %d ",pPacket->GetAccount(),pPacket->GetCode());
			}
			break;
		case 0x01:
			{
				Msg.SetFeeType(pPacket->GetFeeType());
				Msg.SetLeftTime(pPacket->GetLeftTime());
				Msg.SetStorePoint(pPacket->GetStorePoint());
				Msg.SetUserPoint(pPacket->GetUserPoint());

				//计费成功
				g_pLog->FastSaveLog(LOG_FILE_0,"BLRetBillingStart::Execute()...Acc=%s Billing Start ft=%d,lt=%d",
					pPacket->GetAccount(),pPacket->GetFeeType(),pPacket->GetLeftTime());
			}
			break;
		default:
			Assert(FALSE);
		}
		//g_pServerManager->SendPacket(&Msg,WORLD_PLAYER_ID);
		ServerPlayer* pServerPlayer =	
		static_cast<ServerPlayer*>(g_pServerManager->GetServerPlayer(WORLD_PLAYER_ID));
		if(pServerPlayer)
		{
			pServerPlayer->SendPacket(&Msg);

			g_pLog->FastSaveLog(LOG_FILE_0,"BLRetBillingStart::Execute()...Send Packet LWRetBillingStart");
				
		}

	}

		return PACKET_EXE_CONTINUE;

	__LEAVE_FUNCTION

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

	ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer;
	GUID_t guid = pPacket->GetGUID(); // 被请求信息的玩家的 GUID

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

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

	if ( pPacket->GetType() == LEADER_RECRUIT )
	{//队长请求得到征兵信息
		if( pUser->GetTeamID() == INVALID_ID )
		{ 
			Assert( FALSE && "该玩家没有队伍!" );
			return PACKET_EXE_CONTINUE;
		}

		Team* pTeam = g_pTeamList->GetTeam( pUser->GetTeamID() );
		if( pTeam==NULL )
		{
			Assert(FALSE) ;
			return PACKET_EXE_CONTINUE ;
		}

		if ( pTeam->Leader()->m_Member != guid )
		{
			//Assert(FALSE&&"不是队长不可以请求!") ;
			return PACKET_EXE_CONTINUE ;
		}

		//得到自己的征兵条件
		LEADER_INFO_NODE *pLeaderInfo = 0;
		pLeaderInfo = (LEADER_INFO_NODE*)g_pTeamRecruitManager->Get(guid,LEADER_RECRUIT);
		LEADER_RECRUIT_ATTRIB *pMyself = &pLeaderInfo->m_LeaderRecruit;

		//查找满足条件的所有玩家
		IDTable* pTable = g_pTeamRecruitManager->GetMemberTable();

		for( uint i=0; i<MAX_TEAMS; i++ )
		{//分页请求,一次最多50条
			if ( Msg.GetMemberCount() >= ONCE_RECRUIT_LIST_LEN)
			{
				break;
			}			
			
			BOOL IsContinue = FALSE;

			MEMBER_INFO_NODE *pMemberInfo = &g_pTeamRecruitManager->GetMemberRecruitInfo(i);
			if ( pMemberInfo->m_NodeState == NODE_NULL )
			{
				continue;
			}

			RECRUIT_OWNER_INFO *pOther = &pMemberInfo->m_OwnerInfo ;

			if ( pOther->m_Level <= pMyself->m_MaxLevel && pOther->m_Level >= pMyself->m_MinLevel )
			{//等级匹配
				for( int i=0;i<COUATTRIBUTE_NUMBER;i++ )
				{
					if ( pMyself->m_IsInCountry[i] == TRUE && i == pOther->m_Country )
					{//国家匹配
						IsContinue = TRUE;
						break;
					}
				}

				if ( IsContinue == FALSE )
					continue ;

				IsContinue = FALSE;

				//组队目的
				for( int i=0;i<TARGET_NUMBER;i++ )
				{
					if ( pMyself->m_IsTarget[i] == TRUE && 
						pMemberInfo->m_MemberRecruit.m_IsTarget[i] == TRUE )
					{//组队目标有一个匹配就OK
						IsContinue = TRUE;
						break;
					}
				}	

				if ( IsContinue == FALSE )
					continue ;

				IsContinue = FALSE;

				//职业范围
				for( int i=0;i<MATTRIBUTE_NUMBER;i++ )
				{
					if ( pMyself->m_IsMenPaiID[i] == TRUE && i == pOther->m_ManPai )
					{//职业有一个匹配就OK
						IsContinue = TRUE;
						break;
					}
				}	

				if ( IsContinue == TRUE )
				{//增加
					RETURN_RECRUIT_INFO info;
					memset(&info,0,sizeof(RETURN_RECRUIT_INFO));
					info.m_Level = pOther->m_Level;
					info.m_ManPai = pOther->m_ManPai;
					info.m_Country = pOther->m_Country;
					info.m_NameLen = pOther->m_NameLen;

					memcpy(info.m_TeamTarget,pMemberInfo->m_MemberRecruit.m_IsTarget,sizeof(info.m_TeamTarget));
					strncpy((char*)info.m_szUserName,(char*)pOther->m_szUserName,info.m_NameLen);
					memcpy(info.m_szTeamEnounce,pMemberInfo->m_MemberRecruit.m_szTeamEnounce,TEAM_ENOUNCE_LEN-1);

					Msg.AddMember(info);
				}
			}
		}

	}
	else if ( pPacket->GetType() == MEMBER_RECRUIT )
	{//队员请求得到征兵信息
		//得到自己的征兵条件
		MEMBER_INFO_NODE *pMemberInfo = 0;
		pMemberInfo = (MEMBER_INFO_NODE*)g_pTeamRecruitManager->Get(guid,MEMBER_RECRUIT);
		MEMBER_RECRUIT_ATTRIB *pMyself = &pMemberInfo->m_MemberRecruit;

		//查找满足条件的所有玩家
		IDTable* pTable = g_pTeamRecruitManager->GetLeaderTable();

		for( uint i=0; i<MAX_TEAMS; i++ )
		{//分页请求,一次最多50条
			if ( Msg.GetMemberCount() >= ONCE_RECRUIT_LIST_LEN)
			{
				break;
			}			

			BOOL IsContinue = FALSE;

			LEADER_INFO_NODE *pLeaderInfo = &g_pTeamRecruitManager->GetLeaderRecruitInfo(i);
			if ( pLeaderInfo->m_NodeState == NODE_NULL )
			{
				continue;
			}

			RECRUIT_OWNER_INFO *pOther = &pLeaderInfo->m_OwnerInfo ;

			if ( pOther->m_Level <= pMyself->m_MaxLevel && pOther->m_Level >= pMyself->m_MinLevel )
			{//等级匹配
				for( int i=0;i<COUATTRIBUTE_NUMBER;i++ )
				{
					if ( pMyself->m_IsInCountry[i] == TRUE && i == pOther->m_Country )
					{//国家匹配
						IsContinue = TRUE;
						break;
					}
				}

				if ( IsContinue == FALSE )
					continue ;

				IsContinue = FALSE;

				//组队目的
				for( int i=0;i<TARGET_NUMBER;i++ )
				{
					if ( pMyself->m_IsTarget[i] == TRUE && 
						pLeaderInfo->m_LeaderRecruit.m_IsTarget[i] == TRUE )
					{//组队目标有一个匹配就OK
						IsContinue = TRUE;
						break;
					}
				}	

				if ( IsContinue == FALSE )
					continue ;

				if ( IsContinue == TRUE )
				{//增加
					RETURN_RECRUIT_INFO info;
					memset(&info,0,sizeof(RETURN_RECRUIT_INFO));

					info.m_Level = pOther->m_Level;
					info.m_ManPai = pOther->m_ManPai;
					info.m_Country = pOther->m_Country;
					info.m_NameLen = pOther->m_NameLen;

					memcpy(info.m_TeamTarget,pLeaderInfo->m_LeaderRecruit.m_IsTarget,sizeof(info.m_TeamTarget));
					strncpy((char*)info.m_szUserName,(char*)pOther->m_szUserName,info.m_NameLen);
					memcpy(info.m_szTeamEnounce,pLeaderInfo->m_LeaderRecruit.m_szTeamEnounce,TEAM_ENOUNCE_LEN-1);

					Msg.AddMember(info);
				}

			}
		}
	}
	else
	{
		Assert(FALSE&&"组队征兵时类型错误");
	}

	pServerPlayer->SendPacket( &Msg ) ;

	Log::SaveLog( WORLD_LOGFILE, "GWAskTeamRecruitInfo...Success!  GUID=%X", guid );

	return PACKET_EXE_CONTINUE;

	__LEAVE_FUNCTION

		return PACKET_EXE_ERROR;
}
Exemple #22
0
uint WGAskOtherOnlineAttrib_HumanHandler::Execute( WGAskOtherOnlineAttrib_Human* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION

	Assert( MyGetCurrentThreadID()==g_pServerManager->m_ThreadID );

	ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer;
	Assert(pServerPlayer);

	PlayerID_t PlayerID = pPacket->GetDestPlayerID();	//目标玩家的PlayerID
	GamePlayer* pGamePlayer = g_pPlayerPool->GetPlayer(PlayerID);
	if( pGamePlayer==NULL )
	{
		Assert(FALSE);
		return PACKET_EXE_CONTINUE;
	}

	Obj_Human* pHuman = pGamePlayer->GetHuman();
	Assert( pHuman );

	Scene* pScene = pHuman->getScene();
	if ( pScene==NULL )
	{ // 主要是玩家断线
		// Assert( pScene );
		return PACKET_EXE_CONTINUE;
	}

	// 发送人物基本信息
	GWDetailOtherOnlineAttrib_Human Msg;
	Msg.SetPlayerID(pPacket->GetSourcePlayerID());//发起查看者的ID
	Msg.SetLevel(pHuman->GetLevel());
	Msg.SetCountry(pHuman->GetCountry());
	Msg.SetMenpai(pHuman->GetMenPai());
	Msg.SetDataID(pHuman->GetDataID());
	Msg.SetPlayerGUID(pPacket->GetGUID());	//返回GUID,其实就是最初发起者的GUID;)


	pServerPlayer->SendPacket(&Msg);

	// 发送骑乘信息
	INT i=0;
	INT j=0;
	for(i=0; i<HUMAN_PET_MAX_COUNT; ++i){
		const _PET_DB_LOAD* pPetDB = pHuman->GetDB()->GetPet(i);
		if(pPetDB && !pPetDB->m_GUID.IsNull()){
			GWDetailOtherOnlineAttrib_Horse Msg2;
			Msg2.SetPlayerGUID(pPacket->GetGUID());	//返回GUID,其实就是最初发起者的GUID;)
			Msg2.SetPlayerID(pPacket->GetSourcePlayerID());//发起查看者的ID

			Msg2.SetGUID(pPetDB->m_GUID);
			Msg2.SetDataID(pPetDB->m_nDataID);
			Msg2.SetLevel(pPetDB->m_nLevel);
			Msg2.SetGenGu(pPetDB->m_nGenGu);
			Msg2.SetRemainPoint(pPetDB->m_nRemainPoint);
			Msg2.SetExp(pPetDB->m_nExp);
			Msg2.SetGeneration(pPetDB->m_byGeneration);
			Msg2.SetHappiness(pPetDB->m_byHappiness);
			Msg2.SetSpouseGUID(pPetDB->m_SpouseGUID);
			Msg2.SetName(pPetDB->m_szName);
			Msg2.SetNickName(pPetDB->m_szNick);
			Msg2.SetDexPerception(pPetDB->m_iSmartnessPerception);
			Msg2.SetStrPerception(pPetDB->m_iStrengthPerception);
			Msg2.SetIntPerception(pPetDB->m_iMindPerception);
			Msg2.SetConPerception(pPetDB->m_iConstitutionPerception);
			Msg2.SetSavvy(pPetDB->m_iSavvy);
			Msg2.SetMountID(pPetDB->m_nDataID);

			if(pPetDB->m_bMating){
				Msg2.SetHorseState(1/*HorseState_Mating*/);
			}
			if(pPetDB->m_bCheckup){
				Msg2.SetGrowRate((INT)pPetDB->m_fGrowRate);
			}
			else{
				Msg2.SetGrowRate(INVALID_ID);
			}

			for(j=0; j<PET_MAX_SKILL_COUNT; ++j){
				Msg2.SetSkill(j, &(pPetDB->m_SkillList[j]) );
			}

			Msg2.SetCon(pPetDB->m_BaseAttrLevel1.Get(CATTR_LEVEL1_CON));
			Msg2.SetDex(pPetDB->m_BaseAttrLevel1.Get(CATTR_LEVEL1_DEX));
			Msg2.SetInt(pPetDB->m_BaseAttrLevel1.Get(CATTR_LEVEL1_INT));
			Msg2.SetStr(pPetDB->m_BaseAttrLevel1.Get(CATTR_LEVEL1_STR));

			pServerPlayer->SendPacket(&Msg2);
		}
	}

	// 发送人物装备信息
	GWDetailOtherOnlineEquipList_Human Msg3;

	Msg3.SetPlayerGUID(pPacket->GetGUID());	//返回GUID,其实就是最初发起者的GUID;)

	Msg3.SetPlayerID(pPacket->GetSourcePlayerID()); //设置发起查看者的ID
	Msg3.SetAskMode(ASK_EQUIP_ALL);

	for(i=0; i<HEQUIP_NUMBER; i++){
		//if(pFullUserData->m_Equip.IsSet((HUMAN_EQUIP)i) == TRUE){
		const _ITEM* pEquip = const_cast<_EQUIP_DB_LOAD*>(pHuman->GetDB()->GetEquipDB())->GetEquipDB((HUMAN_EQUIP)i);
		if(pEquip && !pEquip->IsNullType() && (pEquip->ItemClass() == ICLASS_EQUIP) )
			Msg3.SetEquipData((HUMAN_EQUIP)i, pEquip);
		//}
	}			

	pServerPlayer->SendPacket(&Msg3);



	return PACKET_EXE_CONTINUE;

__LEAVE_FUNCTION

	return PACKET_EXE_ERROR;
}
Exemple #23
0
UINT LBLAskMigHandler::Execute(LBLAskMig* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION
	
	TID CurrentThreadID = MyGetCurrentThreadID();
	if(CurrentThreadID != g_pServerManager->m_ThreadID)
	{
		Assert(FALSE);
	}

	Assert(pPlayer);
	Assert(pPacket->GetType() == LBLAskMig::BL_ASKMIG);

	if(pPlayer->IsBillingPlayer())
	{
		BillingPlayer* pBillPlayer = static_cast<BillingPlayer*>(pPlayer);

		Assert(pBillPlayer);
		Assert(pPacket);

		LWRetPrize	Msg;
		
		//Msg.SetAccName(pPacket->GetAccount());
		//Msg.SetPrizeUserID(pPacket->GetPacketIndex());
  //      Msg.SetPrizeResult(pPacket->GetPrizeResult());
		//Msg.SetRetType(ASK_NEWPRIZE);

		//if(/*BNPR_SUCCESS*/0x00 == pPacket->GetPrizeResult())
		//{
		//	for(INT i = 0; i < pPacket->GetPrizeNum(); ++i)
		//	{
		//		Msg.AddPrize(pPacket->GetPrize(i));

		//		g_pLog->FastSaveLog(LOG_FILE_0,"LBLAskMig...GetPrize Acc=%s price=%s,num=%d",
		//			pPacket->GetAccount(), pPacket->GetPrize(i)->m_PrizeString, pPacket->GetPrize(i)->m_PrizeNum);
		//	}
		//}
		//else if(/*BNPR_ALREADY_GET*/0x02 == pPacket->GetPrizeResult())
		//{
		//	for(INT i = 0; i < pPacket->GetPrizeNum(); ++i)
		//	{
		//		//已经领过的奖品就没啥意思了
		//		//Msg.AddPrize(pPacket->GetPrize(i));
		//		g_pLog->FastSaveLog(LOG_FILE_0,"LBLAskMig...AlreadyGetPrize Acc=%s price=%s,num=%d Drop",
		//			pPacket->GetAccount(), pPacket->GetPrize(i)->m_PrizeString, pPacket->GetPrize(i)->m_PrizeNum);
		//	}
		//}

		ServerPlayer* pServerPlayer =	
			static_cast<ServerPlayer*>(g_pServerManager->GetServerPlayer(WORLD_PLAYER_ID));
		if(pServerPlayer)
		{
			pServerPlayer->SendPacket(&Msg);
		}

		
		g_pLog->FastSaveLog(LOG_FILE_0,"LBLAskMig::Execute()...OK Acc=%s PUID=%d,Result = %d",
			pPacket->GetAccount(),pPacket->GetPacketIndex(),pPacket->GetMigResult());
	}


	return PACKET_EXE_CONTINUE;

__LEAVE_FUNCTION

	return PACKET_EXE_ERROR;
}
UINT GWChannelCreateHandler::Execute( GWChannelCreate* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION

	ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer ;

	GUID_t Guid = pPacket->GetGUID() ;

	USER* pUser = g_pOnlineUser->FindUser( Guid ) ;
	if( pUser==NULL )
	{
		Log::SaveLog( WORLD_LOGFILE, "GWChannelCreateHandler...User GUID=%X not find!", 
			Guid ) ;

		return PACKET_EXE_CONTINUE ;
	}

	if( pUser->GetChannelID() != INVALID_ID )
	{//此用户已经创建了一个聊天频道
		WGChannelError Msg ;

		Msg.SetPlayerID( pUser->GetPlayerID() ) ;
		Msg.SetGUID( pUser->GetGUID() );
		Msg.SetErrorCode( CHANNEL_ERROR_HASCHANNEL ) ;
		
		pServerPlayer->SendPacket( &Msg ) ;

		Log::SaveLog( WORLD_LOGFILE, "GWChannelCreateHandler...GUID=%X has channel! cannot create!", 
			Guid ) ;

		return PACKET_EXE_CONTINUE ;
	}

	ChannelID_t cid = g_pChatCenter->CreateChatChannel() ;
	if( cid==INVALID_ID )
	{
		WGChannelError Msg ;

		Msg.SetPlayerID( pUser->GetPlayerID() ) ;
		Msg.SetGUID( pUser->GetGUID() );
		Msg.SetErrorCode( CHANNEL_ERROR_CHANNELFULL ) ;
		
		pServerPlayer->SendPacket( &Msg ) ;

		Log::SaveLog( WORLD_LOGFILE, "GWChannelCreateHandler...GUID=%X create fail !", 
			Guid ) ;

		return PACKET_EXE_CONTINUE ;
	}

	//设置自建聊天频道信息
	pUser->SetChannelID( cid );

	//发送结果
	WGChannelResult Msg ;
	Msg.SetPlayerID( pUser->GetPlayerID() ) ;
	Msg.SetReturn( CHANNEL_RESULT_CREATE ) ;
	Msg.SetChannelID( pUser->GetChannelID() ) ;
	
	pServerPlayer->SendPacket( &Msg ) ;

	Log::SaveLog( WORLD_LOGFILE, "GWChannelCreateHandler...GUID=%X ChannelID=%d!", 
		Guid, cid ) ;


	return PACKET_EXE_CONTINUE ;

__LEAVE_FUNCTION

	return PACKET_EXE_ERROR ;
}
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;
}
Exemple #26
0
uint GWAskMailHandler::Execute( GWAskMail* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION

	USER* pUser = g_pOnlineUser->FindUser( pPacket->GetGUID() ) ;
	if( pUser==NULL )
	{
		//玩家不在线,邮件暂时不发了
		//Assert(FALSE) ;

		Log::SaveLog( WORLD_LOGFILE, "GWAskMailHandler...User GUID=%X not find!",
			pPacket->GetGUID() );
		return PACKET_EXE_CONTINUE ;
	}

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

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

	if( pPacket->GetAskType()==ASK_TYPE_LOGIN )
	{
		g_pMailCenter->AskScriptMail( pUser->GetName(), Msg.GetMailList() ) ;

		UINT uMailCount = g_pMailCenter->CheckMail(pUser->GetName());
		if (uMailCount > 0)
		{
			WGNotifyMail NotifyMsg;
			NotifyMsg.SetPlayerID( pUser->GetPlayerID() );
			NotifyMsg.SetMailCount( (UCHAR)(uMailCount>255?255:uMailCount) );
			pServerPlayer->SendPacket( &NotifyMsg );
		}

		if( Msg.GetMailList()->m_Count < 1 )
		{ // 如果没有可执行的脚本邮件,则此消息不往回发.否则会转给客户端,把普通邮件的剩余数量错误设置为0
			return PACKET_EXE_CONTINUE;
		}
	}
	else if( pPacket->GetAskType()==ASK_TYPE_MAIL )
	{
		while(g_pMailCenter->AskMail( pUser->GetName(), Msg.GetMailList() ))
		{
			INT nCount;
			nCount = Msg.GetMailList()->m_Count;
			if( nCount != 1 )
			{ // 这里如果不是 1 封的话处理方式应该有所不同
				Assert( nCount == 1 );
				return PACKET_EXE_CONTINUE;
			}

			if( pUser->ValidateMail( &(Msg.GetMailList()->m_aMail[0]) ) == 0 )
			{ // 邮件有效
				break;
			}
			else
			{ // 无效继续收
				Msg.GetMailList()->CleanUp();
			}
		}

		if( Msg.GetMailList()->m_Count < 1 )
		{ // 一封有效邮件都没有
			return PACKET_EXE_CONTINUE;
		}
	}
	else
	{
		Assert(FALSE) ;
	}

	pServerPlayer->SendPacket( &Msg ) ;

	Log::SaveLog( WORLD_LOGFILE, "GWAskMailHandler...Name=%s MailCount=%d LeftCount=%d",
		pUser->GetName(), Msg.GetMailList()->m_Count, Msg.GetMailList()->m_TotalLeft );

	return PACKET_EXE_CONTINUE ;

__LEAVE_FUNCTION

	return PACKET_EXE_ERROR ;
}
Exemple #27
0
uint GWAskSceneDataHandler::Execute( GWAskSceneData* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION

	//world收到服务器对场景信息的请求
	//根据不同类型,回应不同数据
	ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer ;

	SceneID_t	SceneID		=	pPacket->GetSceneID();
	ID_t		ClientRes	=	pPacket->GetClientRes() ;
	BYTE		bType		=	pPacket->GetType();
	BYTE		ExtraDataL	=	pPacket->GetExtraDataLength();
	CHAR*		ExtraData	=	pPacket->GetExtraData();

	WGRetSceneData Msg ;

	switch(bType)
	{
		case GWAskSceneData::TYPE_COPY:
			{
				g_pSceneInfo->SetSceneClientRes( SceneID, ClientRes ) ;

				Msg.SetSceneID( SceneID ) ;
				Msg.SetClientRes( ClientRes ) ;
				pServerPlayer->SendPacket( &Msg ) ;
			}
			break;

		case GWAskSceneData::TYPE_CITY:
			{
				//收到服务器端城市场景load成功的消息
				//world可以分配自己真实的城市结构了
				GWAskSceneData::CITY_DATA CityData;
				memcpy(&CityData, ExtraData, ExtraDataL);
				SceneID_t	PortSceneID = CityData.m_PortSceneID;
				GuildID_t	nGuildID	= CityData.m_GuildID;

				_SERVER_DATA* pServerData = pServerPlayer->GetServerData();
				City* pCity = g_pCityManager->NewCity();
				pCity->SetSceneID(SceneID);						//城市自己的ID
				pCity->SetPortSceneID(PortSceneID);				//城市的入口场景ID
				pCity->SetGuildID(nGuildID);					//城市的帮会ID
				pCity->SetServerID(pServerData->m_ServerID);	//城市所在服务器
				pCity->LoadBuildingInfo(SceneID);				//读入场景建筑信息

				SCENE_INIT_DATA CityInitData;
				
				CityInitData.m_nDataType	= SCENE_TYPE_CIT;
				CityInitData.m_CityData		= *pCity->GetCityDB();

				Msg.SetSceneID(SceneID);
				Msg.SetSceneInitData(&CityInitData);
				pServerPlayer->SendPacket( &Msg ) ;
			}
			break;

		case GWAskSceneData::TYPE_BATTLE:
			{

			}
			break;
		default:
			break;
	}

	Log::SaveLog( WORLD_LOGFILE, "GWAskSceneDataHandler SceneID=%d", 
		pPacket->GetSceneID() ) ;

	return PACKET_EXE_CONTINUE ;

__LEAVE_FUNCTION

	return PACKET_EXE_ERROR ;
}
UINT GWChannelKickHandler::Execute( GWChannelKick* pPacket, Player* pPlayer )
{
__ENTER_FUNCTION

	ServerPlayer* pSourServerPlayer = (ServerPlayer*)pPlayer ;

	GUID_t sGuid = pPacket->GetSourGUID() ;
	GUID_t dGuid = pPacket->GetDestGUID() ;


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

		return PACKET_EXE_CONTINUE ;
	}

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

		return PACKET_EXE_CONTINUE ;
	}

	if( pSourUser->GetChannelID() == INVALID_ID )
	{//踢人者没有创建频道
		WGChannelError Msg ;
		Msg.SetPlayerID( pSourUser->GetPlayerID() ) ;
		Msg.SetGUID( pSourUser->GetGUID() );
		Msg.SetErrorCode( CHANNEL_ERROR_NOCHANNEL ) ;

		pSourServerPlayer->SendPacket( &Msg ) ;

		Log::SaveLog( WORLD_LOGFILE, "GWChannelKickHandler...User Sour GUID=%X not channel!", 
			sGuid ) ;
	}
	else
	{
		ChatChannel* pChannel = g_pChatCenter->GetChatChannel( pSourUser->GetChannelID() ) ;
		if( pChannel==NULL )
		{
			Assert(FALSE) ;
			return PACKET_EXE_CONTINUE ;
		}

		if( !pChannel->IsMember( pDestUser->GetGUID() ) )
		{//被踢者不在此频道内
			WGChannelError Msg ;
			Msg.SetPlayerID( pSourUser->GetPlayerID() ) ;
			Msg.SetGUID( pSourUser->GetGUID() );
			Msg.SetErrorCode( CHANNEL_ERROR_NOTINCHANNEL ) ;

			pSourServerPlayer->SendPacket( &Msg ) ;

			Log::SaveLog( WORLD_LOGFILE, "GWChannelKickHandler...User Dest GUID=%X not in channel!", 
				dGuid ) ;
		}
		else
		{
			WGChannelResult Msg ;
			Msg.SetReturn( CHANNEL_RESULT_KICKMEMBER ) ;
			Msg.SetChannelID( pSourUser->GetChannelID() ) ;
			Msg.SetGUID( pDestUser->GetGUID() ) ;

			//通知所有频道内的玩家
			for( int i=0; i<pChannel->MemberCount(); i++ )
			{
				GUID_t guid = pChannel->Member( i ) ;
				if( guid==INVALID_ID )
				{
					Assert(FALSE) ;
					continue ;
				}

				USER* pUser = g_pOnlineUser->FindUser( guid ) ;
				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 ) ;
			}

			//删除频道内数据
			pChannel->DelMember( pDestUser->GetGUID() ) ;

			Log::SaveLog( WORLD_LOGFILE, "GWChannelKickHandler...User Dest GUID=%X kicked from ChannelID=%d!", 
				dGuid, pSourUser->GetChannelID() ) ;
		}
	}


	return PACKET_EXE_CONTINUE ;

__LEAVE_FUNCTION

	return PACKET_EXE_ERROR ;
}
UINT GWTeamAppointHandler::Execute( GWTeamAppoint* pPacket, Player* pPlayer )
{
    __ENTER_FUNCTION

    ServerPlayer* pSourServerPlayer = (ServerPlayer*)pPlayer;

    GUID_t sGuid = pPacket->GetSourGUID();
    GUID_t dGuid = pPacket->GetDestGUID();


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

        return PACKET_EXE_CONTINUE;
    }

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

        return PACKET_EXE_CONTINUE;
    }

    if( pSourUser->GetTeamID()==INVALID_ID )
    {   //旧队长不在队伍中
        WGTeamError Msg;
        Msg.SetPlayerID( pSourUser->GetPlayerID() );
        Msg.SetGUID( pSourUser->GetGUID() );
        Msg.SetErrorCode(TEAM_ERROR_APPOINTSOURNOTEAM);
        pSourServerPlayer->SendPacket( &Msg );

        Log::SaveLog( WORLD_LOGFILE, "GWTeamAppointHandler...DestInTeam SourGUID=%X DestGUID=%X",
                      sGuid, dGuid );
    }
    else if( pDestUser->GetTeamID()==INVALID_ID )
    {   //新队长不在队伍中
        WGTeamError Msg;
        Msg.SetPlayerID( pSourUser->GetPlayerID() );
        Msg.SetGUID( pSourUser->GetGUID() );
        Msg.SetErrorCode(TEAM_ERROR_APPOINTDESTNOTEAM);
        pSourServerPlayer->SendPacket( &Msg );

        Log::SaveLog( WORLD_LOGFILE, "GWTeamAppointHandler...DestInTeam SourGUID=%X DestGUID=%X",
                      sGuid, dGuid );
    }
    else if( pDestUser->GetTeamID()!=pSourUser->GetTeamID() )
    {   //两个人不属于同一个队伍
        WGTeamError Msg;
        Msg.SetPlayerID( pSourUser->GetPlayerID() );
        Msg.SetGUID( pSourUser->GetGUID() );
        Msg.SetErrorCode(TEAM_ERROR_APPOINTNOTSAMETEAM);
        pSourServerPlayer->SendPacket( &Msg );

        Log::SaveLog( WORLD_LOGFILE, "GWTeamAppointHandler...DestInTeam SourGUID=%X DestGUID=%X",
                      sGuid, dGuid );
    }
    else
    {   //队伍存在
        if( g_pOnlineUser->AppointTeamLeader(pSourUser, pDestUser) )
        {
            Log::SaveLog( WORLD_LOGFILE, "GWTeamAppointHandler...Success!  sGUID=%X dGUID=%X",
                          sGuid, dGuid );
        }
        else
        {
            Log::SaveLog( WORLD_LOGFILE, "GWTeamAppointHandler...Failed!  sGUID=%X dGUID=%X",
                          sGuid, dGuid );
        }
    }

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