UINT GWUpdateTitleHandler::Execute(GWUpdateTitle* pPacket, Player* pPlayer ) { __ENTER_FUNCTION USER* pUser = g_pOnlineUser->FindUser( pPacket->GetGUID() ); if( pUser==NULL ) {//没有发现在“在线用户列表”里对应此GUID的用户 Log::SaveLog( WORLD_LOGFILE, "GWUpdateTitleHandler...User GUID=%X not find!", pPacket->GetGUID() ); Assert( FALSE && "找不到此人" ); return PACKET_EXE_CONTINUE; } pUser->SetTitle( pPacket->GetTitle() ); Log::SaveLog( WORLD_LOGFILE, "GWUpdateTitleHandler...User GUID=%X Changed Title to Title=%s", pPacket->GetGUID(), pPacket->GetTitle() ); return PACKET_EXE_CONTINUE; __LEAVE_FUNCTION return PACKET_EXE_ERROR; }
uint GWDetailOtherOnlineAttrib_HorseHandler::Execute(GWDetailOtherOnlineAttrib_Horse* pPacket, Player* pPlayer ) { __ENTER_FUNCTION ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer; Assert( pServerPlayer ); GUID_t guid = pPacket->GetPlayerGUID(); USER* pUser = g_pOnlineUser->FindUser(guid); if(pUser){ ID_t ServerID = pUser->GetServerID() ; ServerPlayer* pDestServerPlayer = g_pServerManager->GetServerPlayer( ServerID ) ; if( pDestServerPlayer==NULL ) { Assert(FALSE); } WGDetailOtherOnlineAttrib_Horse Msg; Msg.SetPlayerID(pPacket->GetPlayerID());//发起查看者的ID Msg.SetGUID(pPacket->GetGUID()); Msg.SetDataID(pPacket->GetDataID()); Msg.SetLevel(pPacket->GetLevel()); Msg.SetGenGu(pPacket->GetGenGu()); Msg.SetRemainPoint(pPacket->GetRemainPoint()); Msg.SetExp(pPacket->GetExp()); Msg.SetGeneration(pPacket->GetGeneration()); Msg.SetHappiness(pPacket->GetHappiness()); Msg.SetSpouseGUID(pPacket->GetSpouseGUID()); Msg.SetName(pPacket->GetName()); Msg.SetNickName(pPacket->GetNickName()); Msg.SetDexPerception(pPacket->GetDexPerception()); Msg.SetStrPerception(pPacket->GetStrPerception()); Msg.SetIntPerception(pPacket->GetIntPerception()); Msg.SetConPerception(pPacket->GetConPerception()); Msg.SetSavvy(pPacket->GetSavvy()); Msg.SetMountID(pPacket->GetMountID()); Msg.SetHorseState(pPacket->GetHorseState()); Msg.SetGrowRate(pPacket->GetGrowRate()); for(UINT i=0; i<PET_MAX_SKILL_COUNT; ++i){ Msg.SetSkill(i, pPacket->GetSkill(i)); } Msg.SetCon(pPacket->GetCon()); Msg.SetDex(pPacket->GetDex()); Msg.SetInt(pPacket->GetInt()); Msg.SetStr(pPacket->GetStr()); pDestServerPlayer->SendPacket(&Msg); Log::SaveLog( WORLD_LOGFILE, "GWDetailOtherOnlineAttrib_HorseHandler: ok "); } return PACKET_EXE_CONTINUE; __LEAVE_FUNCTION return PACKET_EXE_ERROR; }
UINT 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 GWMailHandler::Execute( GWMail* pPacket, Player* pPlayer ) { __ENTER_FUNCTION USER* pUser = g_pOnlineUser->FindUser( pPacket->GetMail()->m_szDestName ); if( pUser && (pUser->UserStatus() != US_OFFLINE) ) {//当前用户在线 if( pUser->RecvMail( pPacket->GetMail() ) == FALSE ) { Log::SaveLog( WORLD_LOGFILE, "GWMailHandler...dName=%s refuse sName=%s's mail.", pUser->GetName(), pPacket->GetMail()->m_szSourName ); return PACKET_EXE_CONTINUE; } } else { g_pMailCenter->MailTo( pPacket->GetMail() ); } Log::SaveLog( WORLD_LOGFILE, "GWMailHandler...sName=%s dName=%s", (pPacket->GetMail()->m_SourSize > 0)?pPacket->GetMail()->m_szSourName:"", pPacket->GetMail()->m_szDestName ); return PACKET_EXE_CONTINUE; __LEAVE_FUNCTION return PACKET_EXE_ERROR; }
uint GWHeartBeatHandler::Execute( GWHeartBeat* pPacket, Player* pPlayer ) { __ENTER_FUNCTION ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer ; GUID_t sGUID = pPacket->GetGUID() ; USER* pUser = g_pOnlineUser->FindUser( sGUID ) ; if( pUser==NULL ) { WGNotifyUser Msg ; Msg.SetGUID( sGUID ) ; Msg.SetStatus( WGNotifyUser::NUS_REMOVE ) ; pServerPlayer->SendPacket( &Msg ) ; Log::SaveLog( WORLD_LOGFILE, "GWHeartBeatHandler...User GUID=%X not find! Notify server!", sGUID ) ; return PACKET_EXE_CONTINUE ; } pUser->ResetKickTime() ; Log::SaveLog( WORLD_LOGFILE, "GWHeartBeatHandler...User GUID=%X Status=%d!", sGUID, pUser->UserStatus() ) ; return PACKET_EXE_CONTINUE ; __LEAVE_FUNCTION return PACKET_EXE_ERROR ; }
// 填充密友在线列表 VOID USER::FillOnlineList( RETURN_ONLINE_LIST* pSend ) { __ENTER_FUNCTION Assert( pSend ); const _RELATION_USER* pRUser; for( INT i=0; i<MAX_RELATION_SIZE; ++i ) { pRUser = &(m_RelationData.m_RelationList.m_RelationUsers[i]); if( (pRUser->m_UserGUID != INVALID_ID) && (pRUser->m_nFriendPoint >= g_Config.m_ConfigInfo.m_nPromptPoint) ) { USER* pFriend; pFriend = g_pOnlineUser->FindUser( pRUser->m_UserGUID ); if( pFriend != NULL && pFriend->IsGoodFriend( GetGUID() ) ) // 在线玩家 { _RELATION_ONLINE OnlineRelation; OnlineRelation.SetGUID( pFriend->GetGUID() ); OnlineRelation.SetMood( pFriend->GetMood() ); pSend->AddOnlineRelation( &OnlineRelation ); } } } __LEAVE_FUNCTION }
uint GWCityApplyNewCityHandler::Execute( GWCityApplyNewCity* pPacket, Player* pPlayer ) { __ENTER_FUNCTION ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer; //入口场景ID SceneID_t PortSceneID = pPacket->GetSceneID(); //申请人GUID GUID_t ApplicantGuid = pPacket->GetPlayerGuid(); WGCityError MsgError; USER* pUser = g_pOnlineUser->FindUser( ApplicantGuid ) ; if( pUser==NULL ) { Log::SaveLog( WORLD_LOGFILE, "GWCityApplyNewCityHandler...User GUID=%X not find!", ApplicantGuid ) ; return PACKET_EXE_CONTINUE ; } //这里要判定当前任务是否有权利建立城市,当前工会是否有资格申请城市 GuildID_t guildID = pUser->GetGuildID(); Guild* pGuild = g_pGuildManager->GetGuild( guildID ); //if(!pGuild) //{ // Log::SaveLog( WORLD_LOGFILE, "GWCityApplyNewCityHandler...User Guild not find! guildID = %d", // guildID ) ; // return PACKET_EXE_CONTINUE ; //} //合法 //通知Server去load城市场景,返回城市场景号 WGCityApplyNewCity MsgToServer; MsgToServer.SetSceneID(PortSceneID); MsgToServer.SetPlayerGuid(ApplicantGuid); pServerPlayer->SendPacket( &MsgToServer ); Log::SaveLog( WORLD_LOGFILE, "GWCityApplyNewCityHandler...User GUID=%X Finished", ApplicantGuid ) ; return PACKET_EXE_CONTINUE ; __LEAVE_FUNCTION return PACKET_EXE_ERROR ; }
uint GWBatchMailHandler::Execute( GWBatchMail* pPacket, Player* pPlayer ) { __ENTER_FUNCTION USER* pUser = NULL; BATCH_MAIL* pBatchMail = pPacket->GetBatchMail(); MAIL mail; mail.m_GUID = pBatchMail->GetGUID(); strncpy( mail.m_szSourName, pBatchMail->GetSourName(), MAX_CHARACTER_NAME - 1 ); mail.m_SourSize = (BYTE)strlen( mail.m_szSourName ); strncpy( mail.m_szContex, pBatchMail->GetMailContent(), MAX_MAIL_CONTEX - 1 ); mail.m_ContexSize = (WORD)strlen( mail.m_szContex ); mail.m_uFlag = pBatchMail->GetMailFlag(); mail.m_uCreateTime = pBatchMail->GetCreateTime(); for( BYTE i=0; i<pBatchMail->GetReceiverCount(); ++i ) { strncpy( mail.m_szDestName, pBatchMail->GetDestName(i), MAX_CHARACTER_NAME - 1 ); mail.m_DestSize = (BYTE)strlen( mail.m_szDestName ); pUser = g_pOnlineUser->FindUser( mail.m_szDestName ); if( pUser ) {//当前用户在线 if( pUser->RecvMail( &mail ) == FALSE ) { Log::SaveLog( WORLD_LOGFILE, "GWBatchMailHandler...dName=%s refuse sName=%s's mail.", pUser->GetName(), mail.m_szSourName ); return PACKET_EXE_CONTINUE; } } else { g_pMailCenter->MailTo( &mail ); } Log::SaveLog( WORLD_LOGFILE, "GWBatchMailHandler...sName=%s dName=%s", mail.m_szSourName, mail.m_szDestName ); } 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 GWCountryAPHandler::Execute( GWCountryAP* 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, "GWCountryAPHandler...User GUID=%X not find!", guid ); return PACKET_EXE_CONTINUE; } INT nCountry = pUser->GetCountry(); Country *pCountry = g_pCountryManager->GetCountry(nCountry); if (pCountry) { if (pUser->GetGUID() == pCountry->GetCountryInfo()->m_GuoWang) { BYTE cType = pPacket->GetType(); INT nAP = pPacket->GetAP(); switch (cType) { case 0: pCountry->AddActionPoint(nAP); break; case 1: pCountry->SubActionPoint(nAP); break; } Log::SaveLog( WORLD_LOGFILE, "GWCountryAPHandler...User GUID=%X ChangeAP = %d", guid, nAP); } } return PACKET_EXE_CONTINUE ; __LEAVE_FUNCTION return PACKET_EXE_ERROR ; }
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 GWStopTeamFollowHandler::Execute( GWStopTeamFollow* pPacket, Player* pPlayer ) { __ENTER_FUNCTION GUID_t guid = pPacket->GetGUID(); USER* pUser = g_pOnlineUser->FindUser( guid ); if ( pUser == NULL ) { Assert(FALSE && "user not find!"); return PACKET_EXE_CONTINUE; } if ( pUser->GetTeamID() == INVALID_ID ) { Assert(FALSE && "isn't in a team!"); return PACKET_EXE_CONTINUE; } Team* pTeam = g_pTeamList->GetTeam( pUser->GetTeamID() ); if ( pTeam==NULL ) { Assert(FALSE && "team not found!"); return PACKET_EXE_CONTINUE; } if ( pTeam->GetFollowedMembers()[0] == pUser->GetGUID() ) { // 队长或者前队长的话 pTeam->ClearFollowedMembers(); } else { pTeam->DelFollowedMember(guid); } Log::SaveLog( WORLD_LOGFILE, "GWStopTeamFollow... GUID=%X stop follow team.", guid); return PACKET_EXE_CONTINUE; __LEAVE_FUNCTION return PACKET_EXE_ERROR; }
uint GWAskTeamMemberInfoHandler::Execute( GWAskTeamMemberInfo* pPacket, Player* pPlayer ) { __ENTER_FUNCTION ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer; GUID_t guid = pPacket->GetGUID(); // 被请求信息的玩家的 GUID WGTeamMemberInfo Msg; Msg.SetPlayerID( pPacket->GetObjID() ); Msg.SetGUID( guid ); USER* pUser = g_pOnlineUser->FindUser( guid ); if( pUser == NULL ) { // 离线状态 Log::SaveLog( WORLD_LOGFILE, "GWAskTeamInfoHandler...User GUID=%X not find!", guid ); return PACKET_EXE_CONTINUE; } Msg.SetFamily( pUser->GetMenpai() ); Msg.SetLevel( pUser->GetLevel() ); if( pUser->UserStatus() != US_NORMAL ) { Msg.SetDeadLinkFlag( TRUE ); } else { Msg.SetDeadLinkFlag( FALSE ); } pServerPlayer->SendPacket( &Msg ); Log::SaveLog( WORLD_LOGFILE, "GWAskTeamInfoHandler...User GUID=%X was find!", guid ); return PACKET_EXE_CONTINUE; __LEAVE_FUNCTION return PACKET_EXE_ERROR; }
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 ; }
// 通知在线密友下线信息 VOID USER::InformOfflineMsg() { __ENTER_FUNCTION const _RELATION_USER* pRUser; for( INT i=0; i<MAX_RELATION_SIZE; ++i ) { pRUser = &(m_RelationData.m_RelationList.m_RelationUsers[i]); if( (pRUser->m_UserGUID != INVALID_ID) && (pRUser->m_nFriendPoint >= g_Config.m_ConfigInfo.m_nPromptPoint) ) { USER* pFriend; pFriend = g_pOnlineUser->FindUser( pRUser->m_UserGUID ); if( pFriend != NULL && pFriend->IsGoodFriend( GetGUID() ) ) // 在线玩家 { pFriend->SendRelationOfflineMsg( this ); } } } __LEAVE_FUNCTION }
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 GWEnterTeamFollowHandler::Execute( GWEnterTeamFollow* pPacket, Player* pPlayer ) { __ENTER_FUNCTION GUID_t guid = pPacket->GetGUID(); USER* pUser = g_pOnlineUser->FindUser( guid ); if ( pUser == NULL ) { Assert(FALSE && "user not find!"); return PACKET_EXE_CONTINUE; } if ( pUser->GetTeamID() == INVALID_ID ) { Assert(FALSE && "isn't in a team!"); return PACKET_EXE_CONTINUE; } Team* pTeam = g_pTeamList->GetTeam( pUser->GetTeamID() ); if( pTeam==NULL ) { Assert(FALSE && "team not found!"); return PACKET_EXE_CONTINUE; } pTeam->AddFollowedMember(guid); Log::SaveLog( WORLD_LOGFILE, "GWEnterTeamFollow... GUID=%X start follow team.", guid); return PACKET_EXE_CONTINUE; __LEAVE_FUNCTION return PACKET_EXE_ERROR; }
uint GWAskUserDataHandler::Execute( GWAskUserData* pPacket, Player* pPlayer ) { __ENTER_FUNCTION ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer ; USER* pUser = g_pOnlineUser->FindUser( pPacket->GetGUID() ) ; WGRetUserData Msg ; if( pUser==NULL ) {//没有发现在“在线用户列表”里对应此GUID的用户 Log::SaveLog( WORLD_LOGFILE, "GWAskUserDataHandler...User GUID=%X not find!", pPacket->GetGUID() ) ; //如果是完整的Login 模式 if( g_Config.m_WorldInfo.m_EnableShareMem ) { Msg.SetPlayerID( pPacket->GetPlayerID() ) ; Msg.SetReturn( UDR_NOTFINDUSERDATA ) ; pServerPlayer->SendPacket( &Msg ) ; return PACKET_EXE_CONTINUE ; } //不是完整的login 模式 //测试数据 pUser = g_pOnlineUser->LoadUser( pPacket->GetGUID(), pPacket->GetCountry(), pPacket->GetProfession(),pPacket->GetAccount()) ; if( pUser ) { _HUMAN_DB_LOAD* pDBHuman = &(pUser->GetFullUserData()->m_Human); pUser->SetTeamID( pUser->GetFullUserData()->m_Human.m_TeamID ); //临时测试数据 strncpy( pDBHuman->m_Name, pPacket->GetAccount(), MAX_CHARACTER_NAME-1 ) ; pDBHuman->m_Sex = (BOOL)(pPacket->GetGender()) ; pDBHuman->m_nCountry = pPacket->GetCountry(); pDBHuman->m_MenPai = pPacket->GetProfession(); pDBHuman->m_FaceModel = pPacket->GetFaceModel(); pUser->SetKey( pPacket->GetKey() ); //临时测试数据 g_pOnlineUser->OnUserLogin( pUser ) ; g_pCountryManager->AddCountryUser((COUNTRY_ATTRIBUTE)pUser->GetCountry(), pUser->GetGUID()); Msg.SetPlayerID( pPacket->GetPlayerID() ) ; Msg.SetReturn( UDR_USERDATA ) ; Msg.SetUserData( pUser->GetFullUserData() ) ; //回收数据块, 设置用户状态 g_pOnlineUser->DelData( pUser->GetFullUserData() ) ; //modified by wuwenbin pUser->SetFullUserData( NULL ); //为什么置空,随后FindUser时造成FULLUSERDATA结构为空 pUser->SetUserStatus( US_NORMAL ); pUser->ResetKickTime(); //将用户所在服务器的PlayerID记录到用户数据里 pUser->SetPlayerID( pPacket->GetPlayerID() ); pServerPlayer->SendPacket( &Msg ) ; Log::SaveLog( WORLD_LOGFILE, "GWAskUserDataHandler...Load GUID=%X OK!", pPacket->GetGUID() ) ; } else { Log::SaveLog( WORLD_LOGFILE, "ERROR:GWAskUserDataHandler...Load GUID=%X false!", pPacket->GetGUID() ) ; } //测试数据 // return PACKET_EXE_CONTINUE ; } int iUserStatus = pUser->UserStatus() ; if( pUser->GetKey() != pPacket->GetKey() ) {//验证码错误,警报,也许受到攻击 Msg.SetPlayerID( pPacket->GetPlayerID() ) ; Msg.SetReturn( UDR_KEYERROR ) ; pServerPlayer->SendPacket( &Msg ) ; Log::SaveLog( WORLD_LOGFILE, "GWAskUserDataHandler.Key Error..User GUID=%X Status=%d", pPacket->GetGUID(), iUserStatus ) ; return PACKET_EXE_CONTINUE ; } //将用户所在服务器的PlayerID记录到用户数据里 pUser->SetPlayerID( pPacket->GetPlayerID() ); switch( iUserStatus ) { case US_NONE: { Msg.SetPlayerID( pPacket->GetPlayerID() ) ; Msg.SetReturn( UDR_NOTFINDUSERDATA ) ; pServerPlayer->SendPacket( &Msg ) ; } break ; case US_HOLDUSERDATA: { Msg.SetPlayerID( pPacket->GetPlayerID() ) ; Msg.SetReturn( UDR_USERDATA ) ; Msg.SetUserData( pUser->GetFullUserData() ) ; g_pOnlineUser->DelData( pUser->GetFullUserData() ) ;//回收数据块 // modified by wuwenbin pUser->SetFullUserData( NULL ); //为什么置空,随后FindUser时造成FULLUSERDATA结构为空 pUser->SetUserStatus( US_NORMAL ); pUser->ResetKickTime(); pServerPlayer->SendPacket( &Msg ) ; } break ; case US_NORMAL: case US_OFFLINE: { Msg.SetPlayerID( pPacket->GetPlayerID() ) ; Msg.SetReturn( UDR_USERDATALIVING ) ; pUser->SetUserStatus( US_NORMAL ); pUser->ResetKickTime(); pServerPlayer->SendPacket( &Msg ) ; } break ; case US_CRASH_DOWN://取消对这种情况处理,由其他方式保证这种情况不会出现 { Assert(FALSE); /* WGRetUserData Msg ; Msg.SetPlayerID( pPacket->GetPlayerID() ) ; Msg.SetReturn( UDR_USERSERVERCRASH ) ; pServerPlayer->SendPacket( &Msg ) ; */ } break; case US_WAIT_SHUTDOWN: { Msg.SetPlayerID( pPacket->GetPlayerID() ) ; Msg.SetReturn( UDR_USERSERVERCRASH ) ; pServerPlayer->SendPacket( &Msg ) ; } break ; default : { Assert(FALSE) ; } break ; }; Log::SaveLog( WORLD_LOGFILE, "GWAskUserDataHandler...User GUID=%X Status=%d", pPacket->GetGUID(), iUserStatus ) ; return PACKET_EXE_CONTINUE ; __LEAVE_FUNCTION return PACKET_EXE_ERROR ; }
uint GWTeamKickHandler::Execute( GWTeamKick* pPacket, Player* pPlayer ) { __ENTER_FUNCTION ServerPlayer* pSourServerPlayer = (ServerPlayer*)pPlayer; GUID_t sGuid = pPacket->GetSourGUID(); // 队长 GUID_t dGuid = pPacket->GetDestGUID(); // 倒霉蛋 USER* pSourUser = g_pOnlineUser->FindUser( sGuid ); if( pSourUser==NULL ) { Log::SaveLog( WORLD_LOGFILE, "GWTeamKickHandler...User Sour GUID=%X not find!", sGuid ); return PACKET_EXE_CONTINUE; } TeamID_t tid = pSourUser->GetTeamID(); Team* pTeam = g_pTeamList->GetTeam( tid ); if( pTeam==NULL ) { Log::SaveLog( WORLD_LOGFILE, "GWTeamKickHandler...User sGUID=%X TeamID=%d not find team!", sGuid, tid ); return PACKET_EXE_CONTINUE; } INT nMemberCount = pTeam->MemberCount(); INT i; for( i=0; i<nMemberCount; ++i ) { if ( pTeam->Member(i)->m_Member == dGuid ) { break; } } if( i >= nMemberCount ) { // 被踢者不在队伍里 Log::SaveLog( WORLD_LOGFILE, "GWTeamKickHandler...User dGUID=%X not in sTeamID=%d(sGUID=%X)!", dGuid, tid, sGuid ); return PACKET_EXE_CONTINUE; } if( pTeam->Leader()->m_Member != sGuid ) { // 踢人者不是队长 WGTeamError Msg; Msg.SetPlayerID( pSourUser->GetPlayerID() ); Msg.SetGUID( pSourUser->GetGUID() ); Msg.SetErrorCode( TEAM_ERROR_KICKNOTLEADER ); pSourServerPlayer->SendPacket( &Msg ); Log::SaveLog( WORLD_LOGFILE, "GWTeamKickHandler...User sGUID=%X TeamID=%d not leader!", sGuid, tid ); return PACKET_EXE_CONTINUE; } WGTeamResult Msg; Msg.SetReturn( TEAM_RESULT_TEAMKICK ); Msg.SetGUID( dGuid ); Msg.SetTeamID( tid ); //通知所有组内的玩家 for( int i=0; i<pTeam->MemberCount(); i++ ) { TEAMMEMBER* pMember = pTeam->Member( i ); if( pMember==NULL ) { Assert(FALSE); continue; } USER* pUser = g_pOnlineUser->FindUser( pMember->m_Member ); if( pUser==NULL ) {//如果队员离线,则用户数据是空 continue; } ID_t ServerID = pUser->GetServerID(); ServerPlayer* pServerPlayer = g_pServerManager->GetServerPlayer( ServerID ); if( pServerPlayer==NULL ) { Assert(FALSE); continue; } Msg.SetPlayerID( pUser->GetPlayerID() ); pServerPlayer->SendPacket( &Msg ); } //剔除队员 TEAMMEMBER Member; Member.m_Member = dGuid; pTeam->DelMember( &Member ); //设置被踢者的队伍信息 USER* pDestUser = g_pOnlineUser->FindUser( dGuid ); if ( pDestUser!=NULL ) { pDestUser->SetTeamID( INVALID_ID ); } Log::SaveLog( WORLD_LOGFILE, "GWTeamKickHandler...User sGUID=%X TeamID=%d Success!", sGuid, tid ); return PACKET_EXE_CONTINUE; __LEAVE_FUNCTION return PACKET_EXE_ERROR; }
UINT GWRelationHandler::Execute( GWRelation* pPacket, Player* pPlayer ) { __ENTER_FUNCTION ServerPlayer* pServerPlayer = (ServerPlayer*)pPlayer; GW_RELATION* pRelationPacket = pPacket->GetRelation(); WGRelation Msg; Msg.GetRelation()->CleanUp(); Msg.SetGUID(pRelationPacket->GetGUID()); UCHAR uErr = 0; _RELATION* pRelationData = NULL; USER* pTargetUser = NULL; USER* pUser = g_pOnlineUser->FindUser( pRelationPacket->GetGUID() ); if ( pUser == NULL ) { //没有发现在“在线用户列表”里对应此 GUID 的用户 Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User GUID=%X not find!", pRelationPacket->GetGUID() ); Assert( FALSE && "找不到信息发送者" ); return PACKET_EXE_CONTINUE; } Msg.GetRelation()->SetPlayerID( pUser->GetPlayerID() ); switch( pRelationPacket->m_Type ) { case REQ_RELATIONINFO: { REQUEST_RELATION_INFO& ReqRelation = pRelationPacket->m_RequestInfo; if ( ReqRelation.GetTargetGUID() != INVALID_ID ) { pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetGUID() ); } else if ( strlen(ReqRelation.GetTargetName()) > 0 ) { pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetName() ); } if ( pTargetUser == NULL ) { // 玩家可能不存在也可能不在线,由 Server 来判断 uErr = RET_TARGETNOTONLINE; Msg.GetRelation()->m_RelationGUID.CleanUp(); Msg.GetRelation()->m_RelationGUID.SetTargetGUID( ReqRelation.GetTargetGUID() ); Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User GUID=%X not find!", ReqRelation.GetTargetGUID() ); break; } Msg.GetRelation()->m_Type = RET_RELATIONINFO; RETURN_RELATION_INFO& Relation = Msg.GetRelation()->m_RelationInfo; Relation.CleanUp(); pRelationData = Relation.GetRelationData(); // pRelationData 的数据在 switch 之后填充 Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...get User info of Name=%s!", pTargetUser->GetName() ); } break; case REQ_VIEWPLAYER: { REQUEST_VIEW_PLAYER& Recv = pRelationPacket->m_ViewPlayer; if ( strlen( Recv.GetTargetName() ) > 0 ) { pTargetUser = g_pOnlineUser->FindUser( Recv.GetTargetName() ); } if ( pTargetUser == NULL ) { // 玩家可能不存在也可能不在线 uErr = RET_ERR_TARGETNOTEXIST; Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s not find!", Recv.GetTargetName() ); break; } Msg.GetRelation()->m_Type = RET_VIEWPLAYER; RETURN_VIEW_PLAYER& Send = Msg.GetRelation()->m_ViewPlayer; Send.CleanUp(); // 填充数据 Send.SetGUID( pTargetUser->GetGUID() ); Send.SetName( pTargetUser->GetName() ); // ... Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...View Player: %s!", pTargetUser->GetName() ); } break; case REQ_ADDFRIEND: case REQ_TEMPFRIEND_TO_FRIEND: { // 检查需要添加的好友是否在线,并发回新好友的详细信息,这里不做合法性判断 REQUEST_ADD_RELATION_WITH_GROUP& ReqRelation = pRelationPacket->m_AddRelationWithGroup; if ( ReqRelation.GetTargetGUID() != INVALID_ID ) { pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetGUID() ); } else if ( strlen(ReqRelation.GetTargetName()) > 0 ) { pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetName() ); } if ( pTargetUser == NULL ) { //没有发现在“在线用户列表”里对应此名字的用户 uErr = RET_ERR_TARGETNOTEXIST; Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s not find!", ReqRelation.GetTargetName() ); Assert( FALSE && "找不到该好友" ); break; } // 判断 pTargetUser 是否拒绝被加为好友 if ( pTargetUser->IsCannotAddFriend() ) { uErr = RET_ERR_CANNOT_ADDFRIEND; Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s can't be added!", ReqRelation.GetTargetName() ); break; } if( pUser->IsEnemy( pTargetUser->GetUserCampData() ) ) { uErr = RET_ERR_ISENEMY; Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s is enemy!", ReqRelation.GetTargetName() ); break; } RELATION_TYPE RelationType = pUser->GetRelationType( pTargetUser->GetGUID() ); if ( RelationType != RELATION_TYPE_NONE ) { if ( RelationType == RELATION_TYPE_BLACKNAME ) { uErr = RET_ERR_ISBLACKNAME; } else { uErr = RET_ERR_ISFRIEND; } Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s can't be added2!", ReqRelation.GetTargetName() ); break; } // 加入好友名单 _RELATION_USER RUser; RUser.m_UserGUID = pTargetUser->GetGUID(); RUser.m_RelationType = RELATION_TYPE_FRIEND; RUser.m_nFriendPoint = 0; pUser->AddRelation( pTargetUser->GetGUID(), &RUser ); // 传回去在线信息 if ( pRelationPacket->m_Type == REQ_ADDFRIEND ) { Msg.GetRelation()->m_Type = RET_ADDFRIEND; } else if ( pRelationPacket->m_Type == REQ_TEMPFRIEND_TO_FRIEND ) { Msg.GetRelation()->m_Type = RET_TEMPFRIEND_TO_FRIEND; } RETURN_ADD_RELATION& Relation = Msg.GetRelation()->m_AddRelation; Relation.CleanUp(); Relation.SetRelationType( ReqRelation.GetRelationType() ); Relation.SetGroup( ReqRelation.GetGroup() ); pRelationData = Relation.GetRelationData(); // pRelationData 的数据在 switch 之后填充 Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s added to friend list!", ReqRelation.GetTargetName() ); if ( pTargetUser->UserStatus() == US_NORMAL ) { // 通知被加的人 WGRelation NotifyMsg; NotifyMsg.GetRelation()->CleanUp(); NotifyMsg.GetRelation()->SetPlayerID( pTargetUser->GetPlayerID() ); NotifyMsg.GetRelation()->m_Type = RET_ADDFRIENDNOTIFY; RETURN_NOTIFY_FRIEND& NotifyFriend = NotifyMsg.GetRelation()->m_NotifyFriend; NotifyFriend.CleanUp(); NotifyFriend.SetGUID( pUser->GetGUID() ); NotifyFriend.SetName( pUser->GetName() ); ServerPlayer* pTServerPlayer = g_pServerManager->GetServerPlayer( pTargetUser->GetServerID() ); if( pTServerPlayer==NULL ) { Assert(FALSE); break; } pTServerPlayer->SendPacket( &NotifyMsg ); } } break; case REQ_ADDTOBLACKLIST: case REQ_TEMPFRIEND_ADDTO_BLACKLIST: { // 检查需要添加的是否在线,并发回详细信息,这里不做合法性判断 REQUEST_ADD_RELATION& ReqRelation = pRelationPacket->m_AddRelation; if ( ReqRelation.GetTargetGUID() != INVALID_ID ) { pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetGUID() ); } else if ( strlen(ReqRelation.GetTargetName()) > 0 ) { pTargetUser = g_pOnlineUser->FindUser( ReqRelation.GetTargetName() ); } if ( pTargetUser == NULL ) { //没有发现在“在线用户列表”里对应此名字的用户 uErr = RET_ERR_TARGETNOTEXIST; Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s not find!", ReqRelation.GetTargetName() ); Assert( FALSE && "找不到该人" ); break; } RELATION_TYPE RelationType = pUser->GetRelationType( pTargetUser->GetGUID() ); if ( RelationType != RELATION_TYPE_NONE ) { if ( RelationType == RELATION_TYPE_FRIEND ) { pUser->DelRelation( pTargetUser->GetGUID() ); } else { switch( RelationType ) { case RELATION_TYPE_BLACKNAME: uErr = RET_ERR_ISBLACKNAME; break; case RELATION_TYPE_MARRY: uErr = RET_ERR_SPOUSETOBLACKLIST; break; case RELATION_TYPE_MASTER: uErr = RET_ERR_MASTERTOBLACKLIST; break; case RELATION_TYPE_PRENTICE: uErr = RET_ERR_PRENTICETOBLACKLIST; break; case RELATION_TYPE_BROTHER: uErr = RET_ERR_BROTHERTOBLACKLIST; break; default: Assert(FALSE); return PACKET_EXE_CONTINUE; } Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s can't be added4!", ReqRelation.GetTargetName() ); break; } } // 加入黑名单 _RELATION_USER RUser; RUser.m_UserGUID = pTargetUser->GetGUID(); RUser.m_RelationType = RELATION_TYPE_BLACKNAME; RUser.m_nFriendPoint = 0; pUser->AddRelation( pTargetUser->GetGUID(), &RUser ); // 传回去在线信息 if ( pRelationPacket->m_Type == REQ_ADDTOBLACKLIST ) { Msg.GetRelation()->m_Type = RET_ADDTOBLACKLIST; } else if ( pRelationPacket->m_Type == REQ_TEMPFRIEND_ADDTO_BLACKLIST ) { Msg.GetRelation()->m_Type = RET_TEMPFRIEND_ADDTO_BLACKLIST; } RETURN_ADD_RELATION& Relation = Msg.GetRelation()->m_AddRelation; Relation.CleanUp(); Relation.SetRelationType( ReqRelation.GetRelationType() ); pRelationData = Relation.GetRelationData(); // pRelationData 的数据在 switch 之后填充 Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User Name=%s added to black list!", ReqRelation.GetTargetName() ); } break; case REQ_DELFRIEND: case REQ_DELFROMBLACKLIST: pUser->DelRelation( pRelationPacket->m_RelationGUID.GetTargetGUID() ); return PACKET_EXE_CONTINUE; case REQ_TRANSITION: { RELATION_GUID_UCHAR& Relation = pRelationPacket->m_TransitionRelation; pUser->DelRelation( Relation.GetTargetGUID() ); _RELATION_USER RUser; RUser.m_UserGUID = Relation.GetTargetGUID(); RUser.m_RelationType = (RELATION_TYPE)Relation.GetRelationType(); RUser.m_nFriendPoint = 0; pUser->AddRelation( Relation.GetTargetGUID(), &RUser ); return PACKET_EXE_CONTINUE; } break; case REQ_NEWGOODFRIEND: { // 加入一个亲密好友 pUser->AddGoodFriend( pRelationPacket->m_RelationGUID.GetTargetGUID() ); return PACKET_EXE_CONTINUE; } break; case REQ_RELATIONONLINE: { // 获取密友的在线列表 Msg.GetRelation()->m_Type = RET_ONLINELIST; RETURN_ONLINE_LIST* pSend = &(Msg.GetRelation()->m_RelationOnline); pSend->CleanUp(); pUser->FillOnlineList(pSend); } break; case REQ_MODIFYMOOD: { pUser->SetMood( pRelationPacket->m_ModifyMood.GetMood() ); return PACKET_EXE_CONTINUE; } break; case REQ_MODIFYSETTINGS: { pUser->SetSettings( pRelationPacket->m_Settings.GetSettings() ); return PACKET_EXE_CONTINUE; } break; case REQ_NOTIFY_ADDTEMPFRIEND: { REQUEST_VIEW_PLAYER& Recv = pRelationPacket->m_ViewPlayer; if ( strlen(Recv.GetTargetName()) > 0 ) { pTargetUser = g_pOnlineUser->FindUser( Recv.GetTargetName() ); } if ( pTargetUser == NULL ) { // 玩家可能不存在也可能不在线,由 Server 来判断 Log::SaveLog( WORLD_LOGFILE, "GWRelationHandler...User GUID=%s not find!", Recv.GetTargetName() ); return PACKET_EXE_CONTINUE; } Msg.GetRelation()->m_Type = RET_NOTIFY_ADDTEMPFRIEND; REQUEST_VIEW_PLAYER* pSend = &(Msg.GetRelation()->m_PlayerName); pSend->CleanUp(); pSend->SetTargetName( pUser->GetName() ); } break; default : { Assert(FALSE); return PACKET_EXE_CONTINUE; } } if ( uErr > 0 ) { Msg.GetRelation()->m_Type = uErr; } if ( pRelationData != NULL && pTargetUser != NULL ) { pRelationData->SetGUID( pTargetUser->GetGUID() ); pRelationData->SetName( pTargetUser->GetName() ); pRelationData->SetLevel( pTargetUser->GetLevel() ); pRelationData->SetMenPai( pTargetUser->GetMenpai() ); pRelationData->SetPortrait( pTargetUser->GetPortrait() ); pRelationData->SetGuildID( pTargetUser->GetGuildID() ); pRelationData->SetGuildName( g_pGuildManager->GetGuildName(pTargetUser->GetGuildID()) ); if ( pTargetUser->UserStatus() == US_NORMAL ) { // 只有在线才发剩余信息 pRelationData->SetOnlineFlag(1); pRelationData->SetMood( pTargetUser->GetMood() ); pRelationData->SetTitle( pTargetUser->GetTitle() ); pRelationData->SetSceneID( pTargetUser->GetSceneID() ); if ( pTargetUser->GetTeamID() != INVALID_ID ) { Team* pTeam = g_pTeamList->GetTeam( pTargetUser->GetTeamID() ); if ( pTeam != NULL ) { pRelationData->SetTeamSize( pTeam->MemberCount() ); } } } } pServerPlayer->SendPacket( &Msg ); return PACKET_EXE_CONTINUE; __LEAVE_FUNCTION return PACKET_EXE_ERROR; }
uint 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 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 GWRegisterTeamRecruitHandler::Execute( GWRegisterTeamRecruit* 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, "GWRegisterTeamRecruit...User GUID=%X not find!", guid ) ; return PACKET_EXE_CONTINUE; } 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_RECRUIT_ATTRIB* pRecruit = pPacket->GetLeaderRecruit(); LEADER_INFO_NODE *pData = g_pTeamRecruitManager->GetLeaderNullNode(); pData->m_OwnerInfo.m_Level = pUser->GetLevel() ; pData->m_OwnerInfo.m_ManPai = pUser->GetMenpai(); pData->m_OwnerInfo.m_Country = pUser->GetCountry(); pData->m_OwnerInfo.m_NameLen = (UCHAR)strlen( pUser->GetName() ); strncpy((char*)pData->m_OwnerInfo.m_szUserName,(char*)pUser->GetName(),pData->m_OwnerInfo.m_NameLen) ; pData->SetRecruitData(*pRecruit); g_pTeamRecruitManager->Remove(guid,LEADER_RECRUIT); g_pTeamRecruitManager->Add(guid,pData,LEADER_RECRUIT); } else if ( pPacket->GetType() == MEMBER_RECRUIT ) { //队员发布征兵请示 MEMBER_RECRUIT_ATTRIB* pRecruit = pPacket->GetMemberRecruit(); MEMBER_INFO_NODE *pData = g_pTeamRecruitManager->GetMemberNullNode(); pData->m_OwnerInfo.m_Level = pUser->GetLevel() ; pData->m_OwnerInfo.m_ManPai = pUser->GetMenpai(); pData->m_OwnerInfo.m_Country = pUser->GetCountry(); pData->m_OwnerInfo.m_NameLen = (UCHAR)strlen( pUser->GetName() ); strncpy((char*)pData->m_OwnerInfo.m_szUserName,(char*)pUser->GetName(),pData->m_OwnerInfo.m_NameLen) ; pData->SetRecruitData(*pRecruit); g_pTeamRecruitManager->Remove(guid,MEMBER_RECRUIT); g_pTeamRecruitManager->Add(guid,pData,MEMBER_RECRUIT); } else { //Assert(FALSE&&"组队征兵时类型错误"); } Log::SaveLog( WORLD_LOGFILE, "GWRegisterTeamRecruit...Success! GUID=%X", guid ); return PACKET_EXE_CONTINUE; __LEAVE_FUNCTION return PACKET_EXE_ERROR; }
UINT GWTeamAppointHandler::Execute( GWTeamAppoint* pPacket, Player* pPlayer ) { __ENTER_FUNCTION ServerPlayer* pSourServerPlayer = (ServerPlayer*)pPlayer; GUID_t sGuid = pPacket->GetSourGUID(); GUID_t dGuid = pPacket->GetDestGUID(); USER* pSourUser = g_pOnlineUser->FindUser( sGuid ); if( pSourUser==NULL ) { Log::SaveLog( WORLD_LOGFILE, "GWTeamAppointHandler...User Sour GUID=%X not find!", sGuid ); return PACKET_EXE_CONTINUE; } USER* pDestUser = g_pOnlineUser->FindUser( dGuid ); if( pDestUser==NULL ) { Log::SaveLog( WORLD_LOGFILE, "GWTeamAppointHandler...User Dest GUID=%X not find!", dGuid ); return PACKET_EXE_CONTINUE; } if( pSourUser->GetTeamID()==INVALID_ID ) { //旧队长不在队伍中 WGTeamError Msg; Msg.SetPlayerID( pSourUser->GetPlayerID() ); Msg.SetGUID( pSourUser->GetGUID() ); Msg.SetErrorCode(TEAM_ERROR_APPOINTSOURNOTEAM); pSourServerPlayer->SendPacket( &Msg ); Log::SaveLog( WORLD_LOGFILE, "GWTeamAppointHandler...DestInTeam SourGUID=%X DestGUID=%X", sGuid, dGuid ); } else if( pDestUser->GetTeamID()==INVALID_ID ) { //新队长不在队伍中 WGTeamError Msg; Msg.SetPlayerID( pSourUser->GetPlayerID() ); Msg.SetGUID( pSourUser->GetGUID() ); Msg.SetErrorCode(TEAM_ERROR_APPOINTDESTNOTEAM); pSourServerPlayer->SendPacket( &Msg ); Log::SaveLog( WORLD_LOGFILE, "GWTeamAppointHandler...DestInTeam SourGUID=%X DestGUID=%X", sGuid, dGuid ); } else if( pDestUser->GetTeamID()!=pSourUser->GetTeamID() ) { //两个人不属于同一个队伍 WGTeamError Msg; Msg.SetPlayerID( pSourUser->GetPlayerID() ); Msg.SetGUID( pSourUser->GetGUID() ); Msg.SetErrorCode(TEAM_ERROR_APPOINTNOTSAMETEAM); pSourServerPlayer->SendPacket( &Msg ); Log::SaveLog( WORLD_LOGFILE, "GWTeamAppointHandler...DestInTeam SourGUID=%X DestGUID=%X", sGuid, dGuid ); } else { //队伍存在 if( g_pOnlineUser->AppointTeamLeader(pSourUser, pDestUser) ) { Log::SaveLog( WORLD_LOGFILE, "GWTeamAppointHandler...Success! sGUID=%X dGUID=%X", sGuid, dGuid ); } else { Log::SaveLog( WORLD_LOGFILE, "GWTeamAppointHandler...Failed! sGUID=%X dGUID=%X", sGuid, dGuid ); } } return PACKET_EXE_CONTINUE; __LEAVE_FUNCTION return PACKET_EXE_ERROR; }
UINT 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 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 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 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 LWRetBillingKeepHandler::Execute(LWRetBillingKeep* pPacket, Player* pPlayer ) { __ENTER_FUNCTION enum BillingKeepResult { BKR_SUCCESS = 0x01, //计费成功 BKR_NO_POINT = 0x02, //点数不够 BKR_DB_ERROR = 0x03, //数据库错误 BKR_NOT_START = 0x04, //没开始计费 }; Assert(pPacket); ServerPlayer* pLoginPlayer = (ServerPlayer*)pPlayer ; Assert(pLoginPlayer); USER* pUser = g_pOnlineUser->FindUserByAccount(pPacket->GetAccount()); if(pUser) { BYTE bResult = pPacket->GetResult(); switch(bResult) { case BKR_SUCCESS: { ////pUser->SetLeftTime(pPacket->GetLeftTime()); ////pUser->SetShopPoint(pPacket->GetStorePoint()); ////pUser->SetUserPoint(pPacket->GetUserPoint()); ////pUser->SetStartTime(pUser->GetEndTime()); ////pUser->SetBillingKeepTimes(0); ////g_pLog->FastSaveLog(LOG_FILE_4, "LWRetBillingKeep...acc=%s Success,lt=%d,sp=%d,up=%d,GUID=%X", //// pPacket->GetAccount(),pUser->GetLeftTime(),pUser->GetShopPoint(), //// pUser->GetUserPoint(),pUser->GetGUID()) ; } break; case BKR_NO_POINT: case BKR_DB_ERROR: case BKR_NOT_START: { //WGNotifyUser MsgNotify ; //MsgNotify.SetGUID( pUser->GetGUID() ) ; //MsgNotify.SetStatus( WGNotifyUser::NUS_NEED_SERVER_KICK ) ; //ServerPlayer* pServerPlayer = g_pServerManager->GetServerPlayer( pUser->GetServerID() ); //if( pServerPlayer ) //{ // pServerPlayer->SendPacket( &MsgNotify ) ; //} g_pOnlineUser->BeginKickUser(pUser); g_pLog->FastSaveLog(LOG_FILE_4, "KICK:LWRetBillingKeep...acc=%s Fail,Result=%d,GUID=%X", pPacket->GetAccount(),bResult,pUser->GetGUID()) ; } break; default: break; } } else { //Assert(FALSE); } return PACKET_EXE_CONTINUE; __LEAVE_FUNCTION return PACKET_EXE_ERROR; }