uint GWNotifyUserHandler::Execute( GWNotifyUser* pPacket, Player* pPlayer ) { __ENTER_FUNCTION ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer ; USER* pUser = g_pOnlineUser->FindUser( pPacket->GetGUID() ) ; if( pUser==NULL ) { Log::SaveLog( WORLD_LOGFILE, "GWNotifyUserHandler...User GUID=%X not find!", pPacket->GetGUID(), pPacket->GetStatus() ) ; return PACKET_EXE_CONTINUE ; } if( pPacket->GetStatus()==GWNotifyUser::NUS_NEED_WORLD_KICK ) { g_pOnlineUser->OnUserRemove( pUser ); g_pOnlineUser->DelUser( pUser ) ; Log::SaveLog( WORLD_LOGFILE, "GWNotifyUserHandler...KICK User GUID=%X Status=%d SP=%d DP=%d", pPacket->GetGUID(), pPacket->GetStatus(), pUser->GetPlayerID(), pPacket->GetPlayerID() ) ; } if( pUser->GetPlayerID() != pPacket->GetPlayerID() ) { Log::SaveLog( WORLD_LOGFILE, "ERROR: GWNotifyUserHandler...User GUID=%X Status=%d SP=%d DP=%d", pPacket->GetGUID(), pPacket->GetStatus(), pUser->GetPlayerID(), pPacket->GetPlayerID() ) ; return PACKET_EXE_CONTINUE ; } if( pPacket->GetStatus()==GWNotifyUser::NUS_DISCONNECT ) { pUser->SetUserStatus( US_OFFLINE ); pUser->ResetKickTime(); g_pOnlineUser->OnUserOffLine( pUser ); Log::SaveLog( WORLD_LOGFILE, "GWNotifyUserHandler...User Is Disconnect GUID=%X Status=%d SP=%d DP=%d", pPacket->GetGUID(), pPacket->GetStatus(), pUser->GetPlayerID(), pPacket->GetPlayerID() ) ; } else if( pPacket->GetStatus()==GWNotifyUser::NUS_REMOVE ) { g_pOnlineUser->OnUserRemove( pUser ); g_pOnlineUser->DelUser( pUser ) ; Log::SaveLog( WORLD_LOGFILE, "GWNotifyUserHandler...User Is Remove GUID=%X Status=%d SP=%d DP=%d", pPacket->GetGUID(), pPacket->GetStatus(), pUser->GetPlayerID(), pPacket->GetPlayerID() ) ; } Log::SaveLog( WORLD_LOGFILE, "GWNotifyUserHandler...User GUID=%X Status=%d", pPacket->GetGUID(), pPacket->GetStatus() ) ; 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 ; }
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 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 GWChannelInviteHandler::Execute( GWChannelInvite* 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, "GWChannelInviteHandler...User Sour GUID=%X not find!", sGuid ) ; return PACKET_EXE_CONTINUE ; } USER* pDestUser = g_pOnlineUser->FindUser( dGuid ) ; if( pDestUser==NULL ) { Log::SaveLog( WORLD_LOGFILE, "GWChannelInviteHandler...User Dest GUID=%X not find!", dGuid ) ; return PACKET_EXE_CONTINUE ; } if( pSourUser->GetChannelID() == INVALID_ID ) { //邀请者没有创建频道 WGChannelError Msg ; Msg.SetPlayerID( pSourUser->GetPlayerID() ) ; Msg.SetErrorCode( CHANNEL_ERROR_NOCHANNEL ) ; pSourServerPlayer->SendPacket( &Msg ) ; Log::SaveLog( WORLD_LOGFILE, "GWChannelInviteHandler...User Sour GUID=%X not Create Channel!", sGuid ) ; } else { ChatChannel* pChannel = g_pChatCenter->GetChatChannel( pSourUser->GetChannelID() ) ; if( pChannel==NULL ) { Assert(FALSE) ; return PACKET_EXE_CONTINUE ; } if( pChannel->IsFull() ) { //聊天频道内人数已满 WGChannelError Msg ; Msg.SetPlayerID( pSourUser->GetPlayerID() ) ; Msg.SetErrorCode( CHANNEL_ERROR_CHANNELMEMBERFULL ) ; pSourServerPlayer->SendPacket( &Msg ) ; Log::SaveLog( WORLD_LOGFILE, "GWChannelInviteHandler...User Sour GUID=%X Channel Full!", sGuid ) ; } else if( pChannel->IsMember( pDestUser->GetGUID() ) ) { WGChannelError Msg ; Msg.SetPlayerID( pSourUser->GetPlayerID() ) ; Msg.SetErrorCode( CHANNEL_ERROR_MEMBEREXIST ) ; pSourServerPlayer->SendPacket( &Msg ) ; Log::SaveLog( WORLD_LOGFILE, "GWChannelInviteHandler...User Dest GUID=%X not in ChannelID=%d!", dGuid, pSourUser->GetChannelID() ) ; } else { //添加成员 pChannel->AddMember( pDestUser->GetGUID() ) ; WGChannelResult Msg ; Msg.SetReturn( CHANNEL_RESULT_ADDMEMBER ) ; 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 ) ; } Log::SaveLog( WORLD_LOGFILE, "GWChannelInviteHandler...User Dest GUID=%X join ChannelID=%d!", dGuid, pSourUser->GetChannelID() ) ; } } 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; }
UINT GWFingerHandler::Execute(GWFinger* pPacket,Player* pPlayer) { __ENTER_FUNCTION ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer; GW_FINGER* pRecv = pPacket->GetFinger(); USER* pUser = g_pOnlineUser->FindUser( pRecv->GetGUID() ); if ( pUser == NULL ) { //没有发现在“在线用户列表”里对应此 GUID 的用户 Log::SaveLog( WORLD_LOGFILE, "GWFingerHandler...User GUID=%X not find!", pRecv->GetGUID() ); return PACKET_EXE_CONTINUE; } WGFinger Msg; WG_FINGER* pSend = Msg.GetFinger(); pSend->CleanUp(); pSend->SetPlayerID( pUser->GetPlayerID() ); switch( pRecv->m_Type ) { case FREQ_GUID: // GUID 搜索 { GUID_t guid = pRecv->m_FingerByGUID.GetTargetGUID(); BOOL bOnlineFlag = pRecv->m_FingerByGUID.GetOnlineFlag(); USER* pTargetUser; // 先从 OnlineUser 中查找 pTargetUser = g_pOnlineUser->FindUser(guid); // 找到了直接返回 if ( pTargetUser != NULL ) { pSend->m_Type = FRET_PLAYERLIST; pSend->m_FingerPlayerList.CleanUp(); pSend->m_FingerPlayerList.AddPlayerInfo( pTargetUser->GetUserSimpleData() ); FINGER_PLAYER_INFO* pPlayerInfo; pPlayerInfo = pSend->m_FingerPlayerList.GetLastPlayerInfo(); Assert( pPlayerInfo ); pPlayerInfo->SetOnlineFlag( TRUE ); pPlayerInfo->SetGuildName( g_pGuildManager->GetGuildName(pPlayerInfo->GetGuildID()) ); } else if ( bOnlineFlag ) { // 没有找到则判断是否需要查找离线玩家,不需要返回错误消息 pSend->m_Type = FRET_ERR_NORESULT; } else { // 需要则从离线玩家中查找 pSend->m_Type = FRET_PLAYERLIST; pSend->m_FingerPlayerList.CleanUp(); if ( g_pAllUser->Select( guid, &(pSend->m_FingerPlayerList) ) < 1 ) { // 找到了返回,否则返回错误消息 pSend->m_Type = FRET_ERR_NORESULT; } } } break; case FREQ_NAME: // NAME 搜索 { const CHAR* szName = pRecv->m_FingerByName.GetTargetName(); BOOL bOnlineFlag = pRecv->m_FingerByName.GetOnlineFlag(); BOOL bPreciseFlag = pRecv->m_FingerByName.GetPreciseFlag(); INT nPosition = pRecv->m_FingerByName.GetPosition(); pSend->m_FingerPlayerList.CleanUp(); BOOL bRes; if ( bOnlineFlag ) { // 在线查找 bRes = g_pOnlineUser->Select( szName, &(pSend->m_FingerPlayerList), bPreciseFlag, nPosition ) > 0; } else { // 离线查找 bRes = g_pAllUser->Select( szName, &(pSend->m_FingerPlayerList), bPreciseFlag, nPosition ) > 0; } if ( bRes ) { // 找到了 //用FindUser模糊查找怎么办?,而且pSend->m_FingerPlayerList中已保存有玩家信息。修改:王勇鸷 //USER *pTargetUser = g_pOnlineUser->FindUser(pRecv->m_FingerByName.GetTargetName()); //pSend->m_FingerPlayerList.CleanUp(); //pSend->m_FingerPlayerList.AddPlayerInfo( pTargetUser->GetUserSimpleData() ); //FINGER_PLAYER_INFO* pPlayerInfo; //pPlayerInfo = pSend->m_FingerPlayerList.GetLastPlayerInfo(); //Assert( pPlayerInfo ); //pPlayerInfo->SetOnlineFlag( TRUE ); pSend->m_Type = FRET_PLAYERLIST; } else { // 没找到 pSend->m_Type = FRET_ERR_NORESULT; } } break; case FREQ_ADVANCED: // 高级搜索 { UINT uCount; pSend->m_FingerPlayerList.CleanUp(); // 将参数传给接口,然后查找 uCount = g_pOnlineUser->Select( pRecv->m_AdvancedFinger.GetMenPai(), pRecv->m_AdvancedFinger.GetGuildID(), pRecv->m_AdvancedFinger.GetSex(), pRecv->m_AdvancedFinger.GetBottomLevel(), pRecv->m_AdvancedFinger.GetTopLevel(), &(pSend->m_FingerPlayerList), pRecv->m_AdvancedFinger.GetPosition() ); if ( uCount == 0 ) { // 没找到 pSend->m_Type = FRET_ERR_NORESULT; } else { // 找到了 pSend->m_Type = FRET_PLAYERLIST; } } break; default: { Assert(FALSE); return PACKET_EXE_CONTINUE; } } Log::SaveLog( WORLD_LOGFILE, "GWFingerHandler...%s finger by type=%d!", pUser->GetName(), pRecv->m_Type ); pServerPlayer->SendPacket( &Msg ); 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 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; }
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 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 GWRelationHandler::Execute( GWRelation* pPacket, Player* pPlayer ) { __ENTER_FUNCTION ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer; GW_RELATION* pRelationPacket = pPacket->GetRelation(); WGRelation Msg; WGRelation TargetMsg; Msg.GetRelation()->CleanUp(); TargetMsg.GetRelation()->CleanUp(); UCHAR uErr = 0; UINT UserPoint = 0; UINT TargetUserPoint = 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; } //如果被邀请的人掉线,则给邀请人返回掉线提示信息 if ( pTargetUser->UserStatus() == US_OFFLINE ) { 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_FRIENDADDPOINT: { REQUEST_RELATION_INFO& RegRelation = pRelationPacket->m_RequestInfo; if ( strlen( RegRelation.GetTargetName() ) > 0 ) { pTargetUser = g_pOnlineUser->FindUser( RegRelation.GetTargetName() ); } if ( pTargetUser == NULL ) { // 玩家可能不存在也可能不在线 uErr = RET_ERR_TARGETNOTEXIST; Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s not find!", RegRelation.GetTargetName() ); break; } pUser->SetPoint( RegRelation.GetTargetGUID(), pTargetUser->GetGUID() ); return PACKET_EXE_CONTINUE; } break; case REQ_REJECTADDFRIEND: { //被邀请的人传回来拒绝接受添加好友的请求 REQUEST_ADD_RELATION_WITH_GROUP& ReqRelation = pRelationPacket->m_AddRelationWithGroup; if ( ReqRelation.GetTargetGUID() != INVALID_ID ) { pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetGUID() ); } else if ( strlen(ReqRelation.GetTargetName()) > 0 ) { pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetName() ); } if ( pTargetUser == NULL ) { //如果邀请的人不在线,则不向邀请人发送任何消息 return PACKET_EXE_CONTINUE; } //如果被邀请的人掉线,则给邀请人返回掉线提示信息 if ( pTargetUser->UserStatus() == US_OFFLINE ) { return PACKET_EXE_CONTINUE; } //向邀请人发送拒绝接受加为好友邀请的信息 WGRelation NotifyMsg; NotifyMsg.GetRelation()->CleanUp(); NotifyMsg.GetRelation()->SetPlayerID( pTargetUser->GetPlayerID() ); NotifyMsg.GetRelation()->m_Type = RET_REJECTADDFRIEND; NotifyMsg.GetRelation()->m_NotifyFriend.CleanUp(); NotifyMsg.GetRelation()->m_NotifyFriend.SetGUID( pUser->GetGUID() ); NotifyMsg.GetRelation()->m_NotifyFriend.SetName( pUser->GetName() ); ServerPlayer* pTServerPlayer = g_pServerManager->GetServerPlayer( pTargetUser->GetServerID() ); if( pTServerPlayer==NULL ) { Assert(FALSE); break; } pTServerPlayer->SendPacket( &NotifyMsg ); return PACKET_EXE_CONTINUE; } 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 ) { //没有发现在“在线用户列表”里对应此名字的用户 (这里注释错了,在玩家正确操作离开游戏后,仍有段时间其他玩家可以通过FindUser()函数获得离开游戏玩家的数据) 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; } RELATION_TYPE RelationType = pUser->GetRelationType( pTargetUser->GetGUID() ); if ( RelationType != RELATION_TYPE_NONE ) { if (RelationType == RELATION_TYPE_ENEMY) { // 如果该玩家是仇人,则也可以加为好友 } else if ( RelationType == RELATION_TYPE_BLACKNAME )//(temp)判断被邀请为好友的人是否已经被加入黑名单 { uErr = RET_ERR_ISBLACKNAME; Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s can't be added2!", ReqRelation.GetTargetName() ); break; } else { uErr = RET_ERR_ISFRIEND;//(temp)如果被邀请的人已经是好友了 Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s can't be added2!", ReqRelation.GetTargetName() ); break; } } //如果被邀请的人掉线,则给邀请人返回掉线提示信息 if ( pTargetUser->UserStatus() == US_OFFLINE ) { uErr = RET_ERR_TARGETNOTEXIST; Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s not find!", ReqRelation.GetTargetName() ); break; } //向被邀请加为好友的玩家发出是否同意的消息 if ( pTargetUser->UserStatus() == US_NORMAL ) { WGRelation NotifyMsg; NotifyMsg.GetRelation()->CleanUp(); NotifyMsg.GetRelation()->SetPlayerID( pTargetUser->GetPlayerID() ); NotifyMsg.GetRelation()->m_Type = RET_ASKADDFRIEND; NotifyMsg.GetRelation()->m_NotifyFriend.CleanUp(); NotifyMsg.GetRelation()->m_NotifyFriend.SetGUID( pUser->GetGUID() ); NotifyMsg.GetRelation()->m_NotifyFriend.SetName( pUser->GetName() ); ServerPlayer* pTServerPlayer = g_pServerManager->GetServerPlayer( pTargetUser->GetServerID() ); if( pTServerPlayer==NULL ) { Assert(FALSE); break; } pTServerPlayer->SendPacket( &NotifyMsg ); return PACKET_EXE_CONTINUE; } } 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; // } // //如果被邀请的人掉线,则给邀请人返回掉线提示信息 // if ( pTargetUser->UserStatus() == US_OFFLINE ) // { // uErr = RET_ERR_TARGETNOTEXIST; // Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s not find!", // ReqRelation.GetTargetName() ); // 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_ADDTOENEMY: { // 检查需要添加的是否在线,并发回详细信息,这里不做合法性判断 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_FRIEND || RelationType == RELATION_TYPE_BLACKNAME ) { pUser->DelRelation( pTargetUser->GetGUID() ); pTargetUser->DelRelation( pUser->GetGUID() ); WGRelation MyDelFriendMsg; MyDelFriendMsg.GetRelation()->CleanUp(); MyDelFriendMsg.GetRelation()->SetPlayerID( pUser->GetPlayerID() ); MyDelFriendMsg.GetRelation()->m_Type = RET_DELFRIENDFORADDENEMY; MyDelFriendMsg.GetRelation()->m_RelationGUID.CleanUp(); MyDelFriendMsg.GetRelation()->m_RelationGUID.SetTargetGUID( pTargetUser->GetGUID() ); pServerPlayer->SendPacket( &MyDelFriendMsg ); WGRelation DelFriendMsg; DelFriendMsg.GetRelation()->CleanUp(); DelFriendMsg.GetRelation()->SetPlayerID( pTargetUser->GetPlayerID() ); DelFriendMsg.GetRelation()->m_Type = RET_DELFRIENDFORADDENEMY; DelFriendMsg.GetRelation()->m_RelationGUID.CleanUp(); DelFriendMsg.GetRelation()->m_RelationGUID.SetTargetGUID( pUser->GetGUID() ); ServerPlayer* pTServerPlayer = g_pServerManager->GetServerPlayer( pTargetUser->GetServerID() ); if( pTServerPlayer==NULL ) { Assert(FALSE); break; } pTServerPlayer->SendPacket( &DelFriendMsg ); // 将删除的好友加入到好友递减列表 time_t NowTime = g_pTimeManager->GetANSITime(); pUser->AddRelationDelPoint( pTargetUser->GetGUID(), NowTime ); pTargetUser->AddRelationDelPoint( pUser->GetGUID(), NowTime ); } // 加入仇人名单 _RELATION_USER RUser; RUser.m_UserGUID = pTargetUser->GetGUID(); RUser.m_RelationType = RELATION_TYPE_ENEMY; pUser->AddRelation( pTargetUser->GetGUID(), &RUser ); // 传回去在线信息 Msg.GetRelation()->m_Type = RET_ADDENEMY; 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 enemy list!", ReqRelation.GetTargetName() ); } break; case REQ_DELFROMENEMY: { pUser->DelRelation( pRelationPacket->m_RelationGUID.GetTargetGUID() ); return PACKET_EXE_CONTINUE; } break; // 删除好友得单独处理,因为是双方都要把对方删除 case REQ_DELFRIEND: { // 获得当前的时间 time_t NowTime = g_pTimeManager->GetANSITime(); pUser->DelRelation(pRelationPacket->m_DelFriend.GetGUID()); const CHAR* name = pRelationPacket->m_DelFriend.GetName(); pTargetUser = g_pOnlineUser->FindUser( pRelationPacket->m_DelFriend.GetGUID() ); if ( pTargetUser != NULL ) // 这个时候对方有可能是离线状态,但是服务器有数据,就可以删除 { // 被删除的好友加入到好友度递减列表中 pTargetUser->AddRelationDelPoint( pUser->GetGUID(), NowTime ); pTargetUser->DelRelation( pUser->GetGUID() ); // 向被删的人发送删除好友信息 WGRelation DelMsg; DelMsg.GetRelation()->CleanUp(); DelMsg.GetRelation()->SetPlayerID( pTargetUser->GetPlayerID() ); DelMsg.GetRelation()->m_Type = RET_DELFRIENDBYMAIL; DelMsg.GetRelation()->m_RelationGUID.CleanUp(); DelMsg.GetRelation()->m_RelationGUID.SetTargetGUID( pUser->GetGUID() ); ServerPlayer* pTServerPlayer = g_pServerManager->GetServerPlayer( pTargetUser->GetServerID() ); if( pTServerPlayer==NULL ) { Assert(FALSE); break; } pTServerPlayer->SendPacket( &DelMsg ); } else { // 如果被删除的人不在线 //发一封可执行邮件 //在下次次玩家上线时会由Server执行此邮件对应的脚本,这里只是被删除的好友执行删除操作 //g_pMailCenter->SendScriptMail( name, MAIL_DELFRIEND,pRelationPacket->m_DelFriend.GetGUID(), pUser->GetGUID() ); g_pMailCenter->SendScriptMail( name, MAIL_DELFRIEND, (UINT)(NowTime), pUser->GetGUID() ); } return PACKET_EXE_CONTINUE; } break; // 通过可执行邮件删除好友 case REQ_DELFRIENDBYMAIL: { // 加入到好友递减列表 pUser->AddRelationDelPoint(pRelationPacket->m_DelFriendByMail.GetGUID(), (time_t)(pRelationPacket->m_DelFriendByMail.GetTIME())); // 不管对方是否在线,直接删除 pUser->DelRelation(pRelationPacket->m_DelFriendByMail.GetGUID()); //向自己的客户端发送删除好友信息 WGRelation DelMsg; DelMsg.GetRelation()->CleanUp(); DelMsg.GetRelation()->SetPlayerID( pUser->GetPlayerID() ); DelMsg.GetRelation()->m_Type = RET_DELFRIENDBYMAIL; DelMsg.GetRelation()->m_RelationGUID.CleanUp(); DelMsg.GetRelation()->m_RelationGUID.SetTargetGUID( pRelationPacket->m_DelFriendByMail.GetGUID() ); pServerPlayer->SendPacket( &DelMsg ); return PACKET_EXE_CONTINUE; } break; 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 ); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //*********如果在这将好友移动到黑名单,没有对好友的身份进行验证(师徒,配偶)等关系,但是策划没有写对这些关系进行验证,所以移入黑名单暂时在这处理*****// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //这里执行的是从别的组移动到相应的组(对方有可能不在线),如果是移动到黑名单,则返回一个信息,在这不用考虑 if( Relation.GetRelationType() == RELATION_TYPE_BLACKNAME ) {// 向客户端发回该玩家已经移动到黑名单消息 WGRelation BlackListMsg; BlackListMsg.GetRelation()->CleanUp(); BlackListMsg.GetRelation()->SetPlayerID( pUser->GetPlayerID() ); BlackListMsg.GetRelation()->m_Type = RET_ASKADDTOBLACKLIST; BlackListMsg.GetRelation()->m_NotifyFriend.CleanUp(); BlackListMsg.GetRelation()->m_NotifyFriend.SetGUID( Relation.GetTargetGUID() ); //BlackListMsg.GetRelation()->m_NotifyFriend.SetName( pUser->GetName() ); pServerPlayer->SendPacket( &BlackListMsg ); } else if ( Relation.GetRelationType() == RELATION_TYPE_FRIEND ) {// 向客户端发回该玩家已经移动到好友消息 WGRelation FriendListMsg; FriendListMsg.GetRelation()->CleanUp(); FriendListMsg.GetRelation()->SetPlayerID( pUser->GetPlayerID() ); FriendListMsg.GetRelation()->m_Type = RET_ASKTHROWTOFRIENDLIST; FriendListMsg.GetRelation()->m_NotifyFriend.CleanUp(); FriendListMsg.GetRelation()->m_NotifyFriend.SetGUID( Relation.GetTargetGUID() ); pServerPlayer->SendPacket( &FriendListMsg ); } 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 Name=%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; //case REQ_ADD_NEW_GROUP: // { //// 检查需要添加的是否在线,并发回详细信息,这里不做合法性判断 //REQUEST_ADD_NEW_GROUP& NewGroup = pRelationPacket->m_AddNewGroup; //_RELATION_DB_LOAD &pRelation = pUser->GetFullUserData()->m_Relation; ////检查玩家自定义组情况 //for( int i=0;i<RELATION_GROUP_F5;i++) //{ // int len = (int)strlen(pRelation.m_szName[i] ); // if ( len > 0 ) // { // //判断是否同名 // if ( strcmp(pRelation.m_szName[i],NewGroup.GetGroupName()) == 0 ) // { // //Assert( FALSE && "组同名,不能新建" ); // return PACKET_EXE_CONTINUE; // } // continue; // } // //更新玩家组名,组ID // strncpy((char*)pRelation.m_szName[i],(char*)NewGroup.GetGroupName(),NewGroup.m_uNameSize); // NewGroup.m_uGroupID = i + RELATION_GROUP_F1; // break; //} //if ( i >= RELATION_GROUP_F5 ) //{ // Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Add New Group=%s failed!", // NewGroup.GetGroupName()); // Assert( FALSE && "组太多,不能新建" ); // return PACKET_EXE_CONTINUE; //} //// 传回去信息 //Msg.GetRelation()->m_Type = RET_NEW_GROUP; //Msg.GetRelation()->m_AddNewGroup.SetGroupName(NewGroup.GetGroupName()); // } // break; case REQ_SUREADDFRIEND: {//确定加为好友 // 检查需要添加的好友是否在线,并发回新好友的详细信息,这里不做合法性判断 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 ( pTargetUser->UserStatus() == US_OFFLINE ) { uErr = RET_ERR_TARGETNOTEXIST; Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s not find!", ReqRelation.GetTargetName() ); break; } RELATION_TYPE RelationType = pUser->GetRelationType( pTargetUser->GetGUID() ); if ( RelationType != RELATION_TYPE_NONE ) { if (RelationType == RELATION_TYPE_ENEMY) {// 如果该玩家是仇人,则先删除仇人关系,再加为好友,只在本地删除 pUser->DelRelation( pTargetUser->GetGUID() ); } else if ( RelationType == RELATION_TYPE_BLACKNAME )//(temp)判断被邀请为好友的人是否已经被加入黑名单 { uErr = RET_ERR_ISBLACKNAME; Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s can't be added2!", ReqRelation.GetTargetName() ); break; } else { uErr = RET_ERR_ISFRIEND;//(temp)如果被邀请的人已经是好友了 Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s can't be added2!", ReqRelation.GetTargetName() ); break; } } // 判断确定加好友的玩家在对方关系列表中的关系,如果在对方的仇人列表中,在对方也要将玩家从仇人列表中删除 RELATION_TYPE TargetRelationType = pTargetUser->GetRelationType( pUser->GetGUID() ); if ( TargetRelationType == RELATION_TYPE_ENEMY ) { pTargetUser->DelRelation( pUser->GetGUID() ); } // 加入好友名单 _RELATION_USER RUser; RUser.m_UserGUID = pTargetUser->GetGUID(); RUser.m_RelationType = RELATION_TYPE_FRIEND; RUser.m_nFriendPoint = pUser->GetPoint( pTargetUser->GetGUID() ); // 通过好友度递减列表来获得好友度 UserPoint = RUser.m_nFriendPoint; // 从好友度递减列表中移除 if ( RUser.m_nFriendPoint != 0) { pUser->DelRelationDelPoint( pTargetUser->GetGUID() ); } pUser->AddRelation( pTargetUser->GetGUID(), &RUser ); // 双方都将对方加为好友,而不是单向的添加好友 _RELATION_USER RTarUser; RTarUser.m_UserGUID = pUser->GetGUID(); RTarUser.m_RelationType = RELATION_TYPE_FRIEND; RTarUser.m_nFriendPoint = pTargetUser->GetPoint( pUser->GetGUID() ); TargetUserPoint = RTarUser.m_nFriendPoint; // 从好友递减列表中移除 if ( RTarUser.m_nFriendPoint != 0 ) { pTargetUser->DelRelationDelPoint( pUser->GetGUID() ); } pTargetUser->AddRelation( pUser->GetGUID(), &RTarUser ); // 传回去在线信息 if ( pRelationPacket->m_Type == REQ_SUREADDFRIEND ) { Msg.GetRelation()->m_Type = RET_ADDFRIEND; TargetMsg.GetRelation()->m_Type = RET_ADDFRIEND; } 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 ); //在这也需要向被加为好友的人传回去在线消息 TargetMsg.GetRelation()->SetPlayerID( pTargetUser->GetPlayerID() ); TargetMsg.GetRelation()->m_AddRelation.CleanUp(); TargetMsg.GetRelation()->m_AddRelation.SetRelationType( ReqRelation.GetRelationType() ); TargetMsg.GetRelation()->m_AddRelation.SetGroup( ReqRelation.GetGroup() ); TargetMsg.GetRelation()->m_AddRelation.GetRelationData()->SetGUID( pUser->GetGUID() ); TargetMsg.GetRelation()->m_AddRelation.GetRelationData()->SetName( pUser->GetName() ); TargetMsg.GetRelation()->m_AddRelation.GetRelationData()->SetLevel( pUser->GetLevel() ); TargetMsg.GetRelation()->m_AddRelation.GetRelationData()->SetMenPai( pUser->GetMenpai() ); TargetMsg.GetRelation()->m_AddRelation.GetRelationData()->SetPortrait( pUser->GetPortrait() ); TargetMsg.GetRelation()->m_AddRelation.GetRelationData()->SetGuildID( pUser->GetGuildID() ); TargetMsg.GetRelation()->m_AddRelation.GetRelationData()->SetGuildName( g_pGuildManager->GetGuildName( pUser->GetGuildID()) ); TargetMsg.GetRelation()->m_AddRelation.GetRelationData()->SetOnlineFlag(1); TargetMsg.GetRelation()->m_AddRelation.GetRelationData()->SetMood( pUser->GetMood() ); TargetMsg.GetRelation()->m_AddRelation.GetRelationData()->SetTitle( pUser->GetTitle() ); TargetMsg.GetRelation()->m_AddRelation.GetRelationData()->SetSceneID( pUser->GetSceneID() ); TargetMsg.GetRelation()->m_AddRelation.GetRelationData()->SetPoint( TargetUserPoint ); if (pUser->GetTeamID() != INVALID_ID) { Team* pTeam = g_pTeamList->GetTeam( pUser->GetTeamID() ); if (pTeam !=NULL) { TargetMsg.GetRelation()->m_AddRelation.GetRelationData()->SetTeamSize( pTeam->MemberCount() ); } } pTServerPlayer->SendPacket( &TargetMsg ); } } 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()) ); pRelationData->SetPoint( UserPoint ); 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 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 ; }
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 GWAskUserDataHandler::Execute( GWAskUserData* pPacket, Player* pPlayer ) { __ENTER_FUNCTION ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer ; USER* pUser = g_pOnlineUser->FindUser( pPacket->GetGUID() ) ; PlayerID_t OldPlayerID = INVALID_ID; USER* pOldUser = g_pOnlineUser->FindUserByAccountName( pPacket->GetAccount() ) ; if( pOldUser && pOldUser != pUser ) { OldPlayerID = pOldUser->GetPlayerID(); } if( pUser==NULL ) {//没有发现在“在线用户列表”里对应此GUID的用户 Log::SaveLog( WORLD_LOGFILE, "GWAskUserDataHandler...User GUID=%X not find!", pPacket->GetGUID() ) ; if( g_Config.m_WorldInfo.m_EnableShareMem ) { WGRetUserData Msg ; Msg.SetPlayerID( pPacket->GetPlayerID() ) ; Msg.SetReturn( UDR_NOTFINDUSERDATA ) ; pServerPlayer->SendPacket( &Msg ) ; return PACKET_EXE_CONTINUE ; } // //测试数据 pUser = g_pOnlineUser->LoadUser( pPacket->GetGUID() ) ; if( pUser ) { _HUMAN_DB_LOAD* pDBHuman = &(pUser->GetFullUserData()->m_Human); //临时测试数据 strncpy( pDBHuman->m_Name, pPacket->GetAccount(), MAX_ACCOUNT ) ; pDBHuman->m_Sex = (BOOL)(pPacket->GetGender()) ; pUser->SetKey( pPacket->GetKey() ); //临时测试数据 g_pOnlineUser->OnUserLogin( pUser ) ; WGRetUserData Msg ; Msg.SetPlayerID( pPacket->GetPlayerID() ) ; Msg.SetReturn( UDR_USERDATA ) ; Msg.SetUserData( pUser->GetFullUserData() ) ; Msg.SetPlayerAge( pUser->GetUserAge() ); //回收数据块, 设置用户状态 g_pOnlineUser->DelData( pUser->GetFullUserData() ) ; pUser->SetFullUserData( NULL ); 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() ) {//验证码错误,警报,也许受到攻击 WGRetUserData Msg ; 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: { WGRetUserData Msg ; Msg.SetPlayerID( pPacket->GetPlayerID() ) ; Msg.SetReturn( UDR_NOTFINDUSERDATA ) ; pServerPlayer->SendPacket( &Msg ) ; } break ; case US_HOLDUSERDATA: { WGRetUserData Msg ; Msg.SetPlayerID( pPacket->GetPlayerID() ) ; Msg.SetReturn( UDR_USERDATA ) ; Msg.SetUserData( pUser->GetFullUserData() ) ; Msg.SetPlayerAge( pUser->GetUserAge() ); g_pOnlineUser->DelData( pUser->GetFullUserData() ) ;//回收数据块 pUser->SetFullUserData( NULL ); pUser->SetUserStatus( US_NORMAL ); pUser->ResetKickTime(); pServerPlayer->SendPacket( &Msg ) ; if( OldPlayerID != INVALID_ID ) { WGNotifyUser MsgNotify ; MsgNotify.SetGUID( pOldUser->GetGUID() ) ; MsgNotify.SetStatus( WGNotifyUser::NUS_REMOVE ) ; pServerPlayer->SendPacket( &MsgNotify ) ; } } break ; case US_CHANGESCENE: { BOOL KickPlayerFromOldServer = FALSE; SceneID_t nOldSceneID = pUser->GetOldSceneID(); ID_t nOldServerID; if( nOldSceneID != INVALID_ID && nOldSceneID < (SceneID_t)g_Config.m_SceneInfo.m_SceneCount ) { nOldServerID = g_Config.m_SceneInfo.m_pScene[nOldSceneID].m_ServerID; ServerPlayer* pOldServerPlayer = g_pServerManager->GetServerPlayer( nOldServerID ); if( pOldServerPlayer ) { WGNotifyUser MsgNotify ; MsgNotify.SetGUID( pUser->GetGUID() ) ; MsgNotify.SetStatus( WGNotifyUser::NUS_REMOVE ) ; pOldServerPlayer->SendPacket( &MsgNotify ) ; KickPlayerFromOldServer = TRUE; } } if( KickPlayerFromOldServer ) Log::SaveLog( WORLD_LOGFILE, "GWAskUserDataHandler...Kick OldPlayer GUID=%X OldScene=%d OldServer=%d Success", pUser->GetGUID(), nOldSceneID, nOldServerID ) ; else Log::SaveLog( WORLD_LOGFILE, "GWAskUserDataHandler...Kick OldPlayer GUID=%X OldScene=%d OldServer=%d Faild!!", pUser->GetGUID(), nOldSceneID, nOldServerID ) ; WGRetUserData Msg ; Msg.SetPlayerID( pPacket->GetPlayerID() ) ; Msg.SetReturn( UDR_USERDATA ) ; Msg.SetUserData( pUser->GetFullUserData() ) ; Msg.SetPlayerAge( pUser->GetUserAge() ); g_pOnlineUser->DelData( pUser->GetFullUserData() ) ;//回收数据块 pUser->SetFullUserData( NULL ); pUser->SetUserStatus( US_NORMAL ); pUser->ResetKickTime(); pServerPlayer->SendPacket( &Msg ) ; } break; case US_NORMAL: case US_OFFLINE: { WGRetUserData Msg ; 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: { WGRetUserData Msg ; 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 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 ; }
uint GWTeamLeaderRetInviteHandler::Execute( GWTeamLeaderRetInvite* pPacket, Player* pPlayer ) { __ENTER_FUNCTION GUID_t sGuid = pPacket->GetSourGUID();//邀请人的GUID GUID_t dGuid = pPacket->GetDestGUID();//被邀请人的GUID GUID_t lGuid = pPacket->GetLeaderGUID();//队长的GUID USER* pSourUser = g_pOnlineUser->FindUser( sGuid ); if( pSourUser==NULL ) { Log::SaveLog( WORLD_LOGFILE, "GWTeamLeaderRetInviteHandler...User Sour GUID=%X not find!", sGuid ); return PACKET_EXE_CONTINUE; } USER* pDestUser = g_pOnlineUser->FindUser( dGuid ); if( pDestUser==NULL ) { Log::SaveLog( WORLD_LOGFILE, "GWTeamLeaderRetInviteHandler...User Dest GUID=%X not find!", dGuid ); return PACKET_EXE_CONTINUE; } USER* pLeaderUser = g_pOnlineUser->FindUser( lGuid ); if( pLeaderUser==NULL ) { Log::SaveLog( WORLD_LOGFILE, "GWTeamLeaderRetInviteHandler...User Leader GUID=%X not find!", lGuid ); return PACKET_EXE_CONTINUE; } ID_t SourServerID = pSourUser->GetServerID(); ServerPlayer* pSourServerPlayer = g_pServerManager->GetServerPlayer( SourServerID ); if( pSourServerPlayer==NULL ) { Assert(FALSE); return PACKET_EXE_CONTINUE; } ID_t DestServerID = pDestUser->GetServerID(); ServerPlayer* pDestServerPlayer = g_pServerManager->GetServerPlayer( DestServerID ); if( pDestServerPlayer==NULL ) { Assert(FALSE); return PACKET_EXE_CONTINUE; } ServerPlayer* pLeaderServerPlayer = (ServerPlayer*)pPlayer; if( pSourUser->GetTeamID() != pLeaderUser->GetTeamID() ) { // 邀请人和队长已经不在一个队伍了 WGTeamError lMsg; lMsg.SetPlayerID( pLeaderUser->GetPlayerID() ); lMsg.SetErrorCode( TEAM_ERROR_INVITERNOTINTEAM ); pLeaderServerPlayer->SendPacket( &lMsg ); Log::SaveLog( WORLD_LOGFILE, "GWTeamLeaderRetInviteHandler...Inviter(sGUID=%X) invited dGUID=%X not in Leader's(lGUID=%X) team.", sGuid, dGuid, lGuid ); } //判断双方是否同一国家,不同国家不能组队 INT SourCountry = pSourUser->GetCountry(); INT DestCountry = pDestUser->GetCountry(); //国家不同 if ( SourCountry != DestCountry ) { Log::SaveLog( WORLD_LOGFILE, "GWTeamLeaderRetInviteHandler...SourCountry %d != DestCountry %d. ", SourCountry,DestCountry ); return PACKET_EXE_CONTINUE; } else if( pPacket->GetReturn()==FALSE ) {//队长不同意 WGTeamError sMsg; sMsg.SetPlayerID( pSourUser->GetPlayerID() ); sMsg.SetErrorCode( TEAM_ERROR_INVITELEADERREFUSE ); pSourServerPlayer->SendPacket( &sMsg ); Log::SaveLog( WORLD_LOGFILE, "GWTeamLeaderRetInviteHandler...Invite Leader Refuse sGUID=%X dGUID=%X lGUID=%X", sGuid, dGuid, lGuid ); } else if( pDestUser->GetTeamID() != INVALID_ID ) {//被邀请人已有队伍了 WGTeamError sMsg; sMsg.SetPlayerID( pSourUser->GetPlayerID() ); sMsg.SetErrorCode( TEAM_ERROR_INVITEDESTHASTEAM ); pSourServerPlayer->SendPacket( &sMsg ); WGTeamError lMsg; lMsg.SetPlayerID( pLeaderUser->GetPlayerID() ); lMsg.SetErrorCode( TEAM_ERROR_INVITEDESTHASTEAM ); pLeaderServerPlayer->SendPacket( &lMsg ); Log::SaveLog( WORLD_LOGFILE, "GWTeamLeaderRetInviteHandler...DestInTeam sGUID=%X dGUID=%X lGUID=%X", sGuid, dGuid, lGuid ); } else {//队伍存在 TeamID_t tid = pLeaderUser->GetTeamID(); Team* pTeam = g_pTeamList->GetTeam( tid ); Assert( pTeam ); if( pTeam->IsFull() ) {//队伍人数已经满了 WGTeamError sMsg; sMsg.SetPlayerID( pSourUser->GetPlayerID() ); sMsg.SetErrorCode( TEAM_ERROR_INVITETEAMFULL ); pSourServerPlayer->SendPacket( &sMsg ); WGTeamError lMsg; lMsg.SetPlayerID( pLeaderUser->GetPlayerID() ); lMsg.SetErrorCode( TEAM_ERROR_INVITETEAMFULL ); pLeaderServerPlayer->SendPacket( &lMsg ); Log::SaveLog( WORLD_LOGFILE, "GWTeamLeaderRetInviteHandler...Team Full sGUID=%X dGUID=%X lGUID=%X", sGuid, dGuid, lGuid ); } else //{//同意被邀请人加入队伍 // //将玩家加入队伍 // TEAMMEMBER Member; // Member.m_Member = dGuid; // Member.m_GUIDEx = pDestUser->GetPlayerID(); // Member.m_SceneID = pDestUser->GetSceneID(); // strncpy((char*)Member.m_Name,(char*)pDestUser->GetName(),MAX_CHARACTER_NAME-1); // Member.m_nPortrait = pDestUser->GetPortrait(); // Member.m_uDataID = pDestUser->GetSex(); // Member.m_uFamily = pDestUser->GetMenpai(); // Member.m_Level = pDestUser->GetLevel(); // 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() ); // Msg2.SetFamily( pDestUser->GetMenpai() ); // Msg2.SetLevel( pDestUser->GetLevel() ); // //通知所有组内的玩家 // for( int i=0; i<pTeam->MemberCount(); i++ ) // { // TEAMMEMBER* pMember = pTeam->Member( i ); // if( pMember==NULL ) // { // Assert(FALSE); // continue; // } // if( pMember->m_Member != dGuid ) // { // 将自己以外的玩家传给新玩家 // Msg1.SetReturn( TEAM_RESULT_TEAMREFRESH ); // Msg1.SetName( pMember->m_Name ); // Msg1.SetIcon( pMember->m_nPortrait ); // Msg1.SetDataID( pMember->m_uDataID ); // Msg1.SetFamily( pMember->m_uFamily ); // Msg1.SetGUID( pMember->m_Member ); // Msg1.SetGUIDEx( pMember->m_GUIDEx ); // 将玩家的 PlayerID 传回 // Msg1.SetSceneID( pMember->m_SceneID ); // Msg1.SetLevel( pMember->m_Level ); // pDestServerPlayer->SendPacket( &Msg1 ); // } // 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 ); // } // Log::SaveLog( WORLD_LOGFILE, "GWTeamLeaderRetInviteHandler...AgreeAndInvite! sGUID=%X dGUID=%X lGUID=%X", // sGuid, dGuid, lGuid ); //} { //原先是不用被邀请者同意,直接添加到队伍中,现在得被邀请者同意才能添加到队伍中 ID_t DestServerID = pDestUser->GetServerID(); ServerPlayer* pDestServerPlayer = g_pServerManager->GetServerPlayer( DestServerID ); if( pDestServerPlayer ) { //向被邀请人发送邀请消息 WGTeamAskInvite Msg; Msg.SetPlayerID( pDestUser->GetPlayerID() ); Msg.SetGUID( lGuid );//在这得改成队长的ID否则又是队员邀请,进入了死循环 if ( pSourUser->GetTeamID() != INVALID_ID ) { Team* pTeam = g_pTeamList->GetTeam( pSourUser->GetTeamID() ); Assert( pTeam ); 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 ) {//如果队员离线,则用户数据是空 info.m_PlayerID = INVALID_ID; //continue ; } else info.m_PlayerID = pUser->GetPlayerID(); info.m_NickSize = (UCHAR)strlen(pMember->m_Name); strncpy( (CHAR*)info.m_szNick, pMember->m_Name, info.m_NickSize ); info.m_uFamily = pMember->m_uFamily; info.m_Scene = pMember->m_SceneID; info.m_Level = pMember->m_Level; info.m_uDataID = pMember->m_uDataID; 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, "GWTeamLeaderRetInviteHandler...AskInvite SourGUID=%X DestGUID=%X", sGuid, dGuid ); } } return PACKET_EXE_CONTINUE; __LEAVE_FUNCTION return PACKET_EXE_ERROR; }
uint GWAskOtherOnlineAttrib_HumanHandler::Execute(GWAskOtherOnlineAttrib_Human* pPacket, Player* pPlayer ) { __ENTER_FUNCTION ServerPlayer* pSourceServerPlayer = (ServerPlayer*)pPlayer; Assert( pSourceServerPlayer ); GUID_t guid = pPacket->GetDestGUID(); USER* pDestUser = g_pOnlineUser->FindUser(guid); if(pDestUser){ WGAskOtherOnlineAttrib_Human Msg; Msg.SetGUID(pPacket->GetSourceGUID()); Msg.SetSourcePlayerID(pPacket->GetPlayerID()); Msg.SetDestPlayerID(pDestUser->GetPlayerID()); ID_t ServerID = pDestUser->GetServerID() ; ServerPlayer* pDestServerPlayer = g_pServerManager->GetServerPlayer( ServerID ) ; if( pDestServerPlayer==NULL ) { Assert(FALSE); } pDestServerPlayer->SendPacket(&Msg); /* FULLUSERDATA* pFullUserData = pUser->GetFullUserData(); if(pFullUserData){ // 发送人物基本信息 WGDetailOtherOnlineAttrib_Human Msg; Msg.SetPlayerID(pPacket->GetPlayerID());//发起查看者的ID Msg.SetLevel(pFullUserData->m_Human.m_Level); Msg.SetCountry(pFullUserData->m_Human.m_nCountry); Msg.SetMenpai(pFullUserData->m_Human.m_MenPai); Msg.SetDataID(pFullUserData->m_Human.m_Sex); pServerPlayer->SendPacket(&Msg); // 发送骑乘信息 INT i=0; INT j=0; for(i=0; i<HUMAN_PET_MAX_COUNT; ++i){ if(!pFullUserData->m_PetList.m_aPetDB[i].m_GUID.IsNull()){ WGDetailOtherOnlineAttrib_Horse Msg2; Msg2.SetPlayerID(pPacket->GetPlayerID());//发起查看者的ID Msg2.SetGUID(pFullUserData->m_PetList.m_aPetDB[i].m_GUID); Msg2.SetDataID(pFullUserData->m_PetList.m_aPetDB[i].m_nDataID); Msg2.SetLevel(pFullUserData->m_PetList.m_aPetDB[i].m_nLevel); Msg2.SetGenGu(pFullUserData->m_PetList.m_aPetDB[i].m_nGenGu); Msg2.SetRemainPoint(pFullUserData->m_PetList.m_aPetDB[i].m_nRemainPoint); Msg2.SetExp(pFullUserData->m_PetList.m_aPetDB[i].m_nExp); Msg2.SetGeneration(pFullUserData->m_PetList.m_aPetDB[i].m_byGeneration); Msg2.SetHappiness(pFullUserData->m_PetList.m_aPetDB[i].m_byHappiness); Msg2.SetSpouseGUID(pFullUserData->m_PetList.m_aPetDB[i].m_SpouseGUID); Msg2.SetName(pFullUserData->m_PetList.m_aPetDB[i].m_szName); Msg2.SetNickName(pFullUserData->m_PetList.m_aPetDB[i].m_szNick); Msg2.SetDexPerception(pFullUserData->m_PetList.m_aPetDB[i].m_iSmartnessPerception); Msg2.SetStrPerception(pFullUserData->m_PetList.m_aPetDB[i].m_iStrengthPerception); Msg2.SetIntPerception(pFullUserData->m_PetList.m_aPetDB[i].m_iMindPerception); Msg2.SetConPerception(pFullUserData->m_PetList.m_aPetDB[i].m_iConstitutionPerception); Msg2.SetSavvy(pFullUserData->m_PetList.m_aPetDB[i].m_iSavvy); Msg2.SetMountID(pFullUserData->m_PetList.m_aPetDB[i].m_nDataID); if(pFullUserData->m_PetList.m_aPetDB[i].m_bMating){ Msg2.SetHorseState(1); } if(pFullUserData->m_PetList.m_aPetDB[i].m_bCheckup){ Msg2.SetGrowRate((INT)pFullUserData->m_PetList.m_aPetDB[i].m_fGrowRate); } else{ Msg2.SetGrowRate(INVALID_ID); } for(j=0; j<PET_MAX_SKILL_COUNT; ++j){ Msg2.SetSkill(j, &(pFullUserData->m_PetList.m_aPetDB[i].m_SkillList[j]) ); } Msg2.SetCon(pFullUserData->m_PetList.m_aPetDB[i].m_BaseAttrLevel1.Get(CATTR_LEVEL1_CON)); Msg2.SetDex(pFullUserData->m_PetList.m_aPetDB[i].m_BaseAttrLevel1.Get(CATTR_LEVEL1_DEX)); Msg2.SetInt(pFullUserData->m_PetList.m_aPetDB[i].m_BaseAttrLevel1.Get(CATTR_LEVEL1_INT)); Msg2.SetStr(pFullUserData->m_PetList.m_aPetDB[i].m_BaseAttrLevel1.Get(CATTR_LEVEL1_STR)); pServerPlayer->SendPacket(&Msg2); } } // 发送人物装备信息 WGDetailOtherOnlineEquipList_Human Msg3; Msg3.SetPlayerID(pPacket->GetPlayerID()); //设置发起查看者的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 = pFullUserData->m_Equip.GetEquipDB((HUMAN_EQUIP)i); if(pEquip && !pEquip->IsNullType() && (pEquip->ItemClass() == ICLASS_EQUIP) ) Msg3.SetEquipData((HUMAN_EQUIP)i, pEquip); //} } pServerPlayer->SendPacket(&Msg3); } */ } else{ // 通知Client该玩家不在线 WGOperateResult Msg; Msg.SetPlayerID(pPacket->GetPlayerID()); Msg.setResult(OR_THIS_PLAYER_IS_OFFLINE); pSourceServerPlayer->SendPacket(&Msg); } Log::SaveLog( WORLD_LOGFILE, "GWAskOtherOnlineAttrib_HumanHandler: ok guid=%X", guid); 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; }
uint GWAskTeamInfoHandler::Execute( GWAskTeamInfo* 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, "GWAskTeamInfoHandler...User GUID=%X not find!", guid ); return PACKET_EXE_CONTINUE; } if( pUser->GetTeamID() == INVALID_ID ) { return PACKET_EXE_CONTINUE; } Team* pTeam = g_pTeamList->GetTeam( pUser->GetTeamID() ); if( pTeam==NULL ) { Assert(FALSE) ; return PACKET_EXE_CONTINUE ; } else { TEAMMEMBER Member; Member.m_Member = pUser->GetGUID(); if ( pTeam->IsMember( &Member ) == FALSE ) { // 某些情况下,玩家保存了过期的队伍号 AssertEx( FALSE, "过期队伍号,忽略。" ); return PACKET_EXE_CONTINUE; } } WGTeamList Msg; Msg.SetPlayerID(pPacket->GetPlayerID()); Msg.SetTeamID( pUser->GetTeamID() ); Msg.SetGUID( guid ); WGTeamResult MsgtoEveryMember; // 通知其他队员某人进入新场景了 MsgtoEveryMember.SetReturn( TEAM_RESULT_ENTERSCENE ); MsgtoEveryMember.SetTeamID( pTeam->GetTeamID() ); MsgtoEveryMember.SetGUID( pUser->GetGUID() ); MsgtoEveryMember.SetGUIDEx( pUser->GetPlayerID() ); MsgtoEveryMember.SetIcon( pUser->GetPortrait() ); MsgtoEveryMember.SetSceneID( pUser->GetSceneID() ); for(int i=0; i<pTeam->MemberCount(); ++i) { TEAMMEMBER* pMember = pTeam->Member( i ); if( pMember==NULL ) { Assert(FALSE); continue; } USER* pDestUser = g_pOnlineUser->FindUser( pMember->m_Member ); if( pDestUser==NULL ) { Assert(FALSE); continue; } ID_t ServerID = pDestUser->GetServerID() ; ServerPlayer* pDestServerPlayer = g_pServerManager->GetServerPlayer( ServerID ) ; if( pDestServerPlayer==NULL ) { Assert(FALSE) ; continue ; } if( pUser->GetGUID() != pDestUser->GetGUID() ) { MsgtoEveryMember.SetPlayerID( pDestUser->GetPlayerID() ) ; pDestServerPlayer->SendPacket( &MsgtoEveryMember ); } TEAM_LIST_ENTRY entry; entry.SetGUID( pDestUser->GetGUID() ); entry.SetSceneID( pDestUser->GetSceneID() ); entry.SetExtraID( pDestUser->GetPlayerID() ); entry.SetName( pDestUser->GetName() ); entry.SetIcon( pDestUser->GetPortrait() ); entry.SetDataID( pDestUser->GetSex() ); Msg.AddTeamMember( entry ); } pServerPlayer->SendPacket( &Msg ); if ( pTeam->GetFollowedmemberCount()>0 ) { GUID_t* FollowedMembers = pTeam->GetFollowedMembers(); BOOL flag; flag = FALSE; for( INT i=0; i<pTeam->GetFollowedmemberCount(); ++i ) { if ( FollowedMembers[i] == guid ) { // 如果身处组队跟随状态则发送组队列表 flag = TRUE; break; } } if ( flag == TRUE ) { WGTeamFollowList FollowListMsg; FollowListMsg.SetPlayerID(pPacket->GetPlayerID()); FollowListMsg.SetGUID( pPacket->GetGUID() ); for( INT i=0; i<pTeam->GetFollowedmemberCount(); ++i ) { FollowListMsg.AddFollowMember(FollowedMembers[i]); } pServerPlayer->SendPacket( &FollowListMsg ); } } Log::SaveLog( WORLD_LOGFILE, "GWAskTeamInfoHandler...Success! GUID=%X", guid ); 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 GWSetTeamDistribModeHandler::Execute( GWSetTeamDistribMode* pPacket, Player* pPlayer ) { __ENTER_FUNCTION BYTE nMode = pPacket->getMode();//mode TeamID_t nTeamID = pPacket->getTeamID();//TeamID GUID_t LeaderGuid = pPacket->getLeaderID();//Leader的GUID USER* pLeaderUser = g_pOnlineUser->FindUser( LeaderGuid ); if( pLeaderUser==NULL ) { Log::SaveLog( WORLD_LOGFILE, "GWSetTeamDistribMode...User Leader GUID=%X not find!", LeaderGuid ); return PACKET_EXE_CONTINUE; } if (nMode>=ITEM_DISTRIB_NUM) { Log::SaveLog( WORLD_LOGFILE, "GWSetTeamDistribMode...MODE=%X error!", nMode ); return PACKET_EXE_CONTINUE; } ServerPlayer* pLeaderServerPlayer = (ServerPlayer*)pPlayer; if( pLeaderUser->GetTeamID() == INVALID_ID ) { //无队伍 WGTeamError lMsg; lMsg.SetPlayerID( pLeaderUser->GetPlayerID() ); lMsg.SetErrorCode( TEAM_ERROR_DISTRIBNOLEADER ); pLeaderServerPlayer->SendPacket( &lMsg ); Log::SaveLog( WORLD_LOGFILE, "GWSetTeamDistribMode... LeaderGuid=%X!", LeaderGuid ); } else {//队伍存在 TeamID_t tid = pLeaderUser->GetTeamID(); Team* pTeam = g_pTeamList->GetTeam( tid ); Assert( pTeam ); if( pTeam->Leader()->m_Member != LeaderGuid ) { //队长GUID和队伍中记录的队长GUID不符 WGTeamError sMsg; sMsg.SetPlayerID( pLeaderUser->GetPlayerID() ); sMsg.SetErrorCode( TEAM_ERROR_DISTRIBNOLEADER ); pLeaderServerPlayer->SendPacket( &sMsg ); Log::SaveLog( WORLD_LOGFILE, "GWSetTeamDistribMode... LeaderGuid=%X!", LeaderGuid ); } else {// pTeam->SetDistribMode(nMode); WGRetTeamDistribMode Msg; Msg.setLeaderID( pLeaderUser->GetPlayerID() ); Msg.setTeamID(pLeaderUser->GetTeamID()); Msg.setMode(nMode); pLeaderServerPlayer->SendPacket( &Msg ); }//end for Log::SaveLog( WORLD_LOGFILE, "GWSetTeamDistribMode...Success! GUID=%X", LeaderGuid ); } return PACKET_EXE_CONTINUE; __LEAVE_FUNCTION return PACKET_EXE_CONTINUE; }
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 GWChannelDismissHandler::Execute( GWChannelDismiss* 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, "GWChannelDismissHandler...User GUID=%X not find!", Guid ) ; return PACKET_EXE_CONTINUE ; } if( pUser->GetChannelID() == INVALID_ID ) { Log::SaveLog( WORLD_LOGFILE, "GWChannelDismissHandler...User GUID=%X not channel!", Guid ) ; return PACKET_EXE_CONTINUE ; } ChatChannel* pChannel = g_pChatCenter->GetChatChannel( pUser->GetChannelID() ) ; if( pChannel==NULL ) { Log::SaveLog( WORLD_LOGFILE, "GWChannelDismissHandler...User GUID=%X cannot find channel!", Guid ) ; return PACKET_EXE_CONTINUE ; } WGChannelResult Msg ; Msg.SetReturn( CHANNEL_RESULT_DISMISS ) ; Msg.SetChannelID( pUser->GetChannelID() ) ; //通知所有频道内的玩家 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 ) ; } //清除自建聊天频道信息 g_pChatCenter->DestoryChatChannel( pUser->GetChannelID() ) ; //清除用户数据 pUser->SetChannelID( INVALID_ID ); Log::SaveLog( WORLD_LOGFILE, "GWChannelDismissHandler...User GUID=%X ChatChannel Dismiss!", Guid ) ; return PACKET_EXE_CONTINUE ; __LEAVE_FUNCTION return PACKET_EXE_ERROR ; }