#include "stdafx.h" #include "./FriendInvitationRecallproc.h" // implemented by _KR_0_20091021_FIRENDINVITATION_EXTEND #include "SolarDateTime.h" #include "DominationInfoParser.h" FriendInvitationRecallProc::FriendInvitationRecallProc(void) { } FriendInvitationRecallProc::~FriendInvitationRecallProc(void) { } VOID FriendInvitationRecallProc::SendRecallTimeSelect(CHARGUID charGUID, Player *pPlayer) { MSG_DG_EVENT_INVITATEFRIEND_RECALLSELECT_SYN msg; msg.CharGUID = charGUID; if(!pPlayer->SendToGameDBPServer(&msg, sizeof(msg))) { SUNLOG( eCRITICAL_LOG, "Send RecallTimeSelect fail (%u)", msg.CharGUID); } } VOID FriendInvitationRecallProc::SendRecallFailMsg(Player* pPlayer, BYTE ErrCode) { MSG_CG_EVENT_INVITATEFRIEND_RECALL_NAK Msg; Msg.m_byErrorCode = ErrCode; pPlayer->SendPacket(&Msg, sizeof(Msg)); } BOOL FriendInvitationRecallProc::IsRecalltimeExpired(Player* pPlayer, DWORD FriendGUID) { DWORD64 RecallTime = pPlayer->GetInvitateFriend().GetRecallTime(FriendGUID); DWORD64 CurrentTiem; util::GetDateTime_YYYYMMDDHHMMSS(CurrentTiem); if(RecallTime + 10000 > CurrentTiem) { MSG_CG_EVENT_INVITATEFRIEND_RECALL_NAK Nmsg; Nmsg.m_byErrorCode = MSG_CG_EVENT_INVITATEFRIEND_RECALL_NAK::RECALLTIME_SHORTAGE; Nmsg.m_LeftTime = CurrentTiem - RecallTime; pPlayer->SendPacket(&Nmsg, sizeof(Nmsg)); return FALSE; } return TRUE; } VOID FriendInvitationRecallProc::SendRecallQuestionMsg(Player* pPlayer, Player* pRecallPlayer) { MSG_CG_EVENT_INVITATEFRIEND_RECALL_QUESTION_SYN msg; msg.FriendGUID = pPlayer->GetCharGuid(); _tcsncpy( msg.FriendName, pPlayer->GetCharName(), MAX_CHARNAME_LENGTH ); msg.FriendName[MAX_CHARNAME_LENGTH] = '\0'; if(!pRecallPlayer->SendPacket(&msg, sizeof(msg))) { SendRecallFailMsg(pPlayer, MSG_CG_EVENT_INVITATEFRIEND_RECALL_NAK::SENDFAIL); } } BOOL FriendInvitationRecallProc::IsPossibileReCallLocation(Player* pPlayer, Player* pRecallPlayer) { GameField *pRecallField = pRecallPlayer->GetField(); if(!pRecallField) { SendRecallFailMsg(pPlayer, MSG_CG_EVENT_INVITATEFRIEND_RECALL_NAK::OTHERZONE_FRIEND); return FALSE; } GameField *pField = pPlayer->GetField(); if(!pField) { SendRecallFailMsg(pPlayer, MSG_CG_EVENT_INVITATEFRIEND_RECALL_NAK::OTHERZONE_ME); return FALSE; } else { //¹ö±×¼öÁ¤:5810 ¹®»óÇö 2010-02-04 ¸ðµç±¹°¡°øÅë ÇÇÀǼºÀüÀ¸·Î ¼ÒȯµÇ´Â ¹ö±× ¼öÁ¤ //Áö¿ªÁ¡·ÉÀü ¸Ê¿¡¼­´Â ¼ÒȯÀ» »ç¿ëÇÒ¼ö ¾ø´Ù. if(0 != DominationInfoParser::Instance()->GetDominationLinkMapCode(pField->GetFieldCode())) { SendRecallFailMsg(pPlayer, MSG_CG_EVENT_INVITATEFRIEND_RECALL_NAK::OTHERZONE_ME); return FALSE; } } return TRUE; } BOOL FriendInvitationRecallProc::SendRecallPosition(Player* pPlayer, Player* pRecallPlayer) { if(pRecallPlayer->ReCallPlayer(pRecallPlayer->GetCharName(), 0, pPlayer->GetField()->GetFieldCode(), pPlayer->GetRandomPosInAround(3), ePORTAL_TYPE_FIRENDINVITATED_EVENT, INVALID_POSTYPE_VALUE, 0)) { return TRUE; } return FALSE; /* MSG_AG_GM_GO_CMD AGMsg; //¸®ÄÝÀ¯Àú¿¡°Ô ¸®ÄÝÇÒ À§Ä¡ Á¤º¸ Àü¼Û _tcsncpy( AGMsg.m_szCharName, pRecallPlayer->GetCharName(), MAX_CHARNAME_LENGTH ); AGMsg.m_szCharName[MAX_CHARNAME_LENGTH] = '\0'; AGMsg.m_RoomKey = 0; //¹«Á¶°Ç Çʵå AGMsg.m_FieldCode = pPlayer->GetField()->GetFieldCode(); pRecallPlayer->GetPos( &AGMsg.m_vCurPos ); AGMsg.m_vDestPos = pPlayer->GetRandomPosInAround( 3 ); AGMsg.m_PortalType = ePORTAL_TYPE_FIRENDINVITATED_EVENT; AGMsg.m_atItemPos = INVALID_POSTYPE_VALUE;//»ç¿ë¾ÈµÊ AGMsg.m_atItemCode = 0;//»ç¿ë¾ÈµÊ pRecallPlayer->SendPacket( &AGMsg, sizeof(AGMsg) ); */ } VOID FriendInvitationRecallProc::SendRecallTimeUpdate(Player* pPlayer, Player* pRecallPlayer) { MSG_DG_EVENT_INVITATEFRIEND_RECALLUPDATE_CMD Msg; //¸®ÄÝÇÑ ½Ã°£ DB ¿¡ ÀÛ¼º Msg.CharGUID = pPlayer->GetCharGuid(); Msg.FriendGUID = pRecallPlayer->GetCharGuid(); util::GetDateTime_YYYYMMDDHHMMSS(Msg.RecallTime); pPlayer->GetInvitateFriend().UpdateReCallTime(pRecallPlayer->GetCharGuid(), Msg.RecallTime); pPlayer->SendToGameDBPServer(&Msg, sizeof(Msg)); } VOID FriendInvitationRecallProc::ReCallUser(Player* pPlayer, Player* pRecallPlayer) { if(!IsPossibileReCallLocation(pPlayer, pRecallPlayer)) return; if(SendRecallPosition(pPlayer, pRecallPlayer)) { SendRecallTimeUpdate(pPlayer, pRecallPlayer); SendRecallSucceedMsg(pPlayer); } } VOID FriendInvitationRecallProc::SendRecallSucceedMsg(Player* pPlayer) { MSG_CG_EVENT_INVITATEFRIEND_RECALL_ACK ACMsg; //¸®ÄÝÇÑ À¯Àú¿¡°Ô ¼º°ø ¸Þ½ÃÁö pPlayer->SendPacket(&ACMsg, sizeof(ACMsg)); } BOOL FriendInvitationRecallProc::IsRequestRecall(Player* pPlayer, DWORD FriendGUID) { DWORD64 CurTime; util::GetDateTime_YYYYMMDDHHMMSS(CurTime); DWORD64 PreRecall_RequestTime = pPlayer->GetInvitatedFriendRecallRequestTime(FriendGUID); if(PreRecall_RequestTime + (FRIENDINVITATION_RECALL_MSGBOX_MAXTIME/1000) > CurTime) { return TRUE; } pPlayer->SetInvitatedFriendRecallRequestTime(FriendGUID, CurTime); return FALSE; } VOID FriendInvitationRecallProc::ReCallACK(const Player* Caller, const CHARGUID CalleeGUID) { const Player * Callee = PlayerManager::Instance()->FindPlayerByCharKey( CalleeGUID ); ASSERT( Callee ); if(!Callee) { MessageOut( eCRITICAL_LOG, "AG_EVENT_RECALL_ACK Not Found User GUID [%u]", CalleeGUID ); } else { //·Î±×¸¦ ³²±ä´Ù. GAMELOG->LogAction(ACT_FRIENDINVITATION_RECALL, const_cast(Caller), const_cast(Callee)); } } VOID FriendInvitationRecallProc::ReCallNAK(Player* Caller, const BYTE ErrorCode) { SendRecallFailMsg(Caller, MSG_CG_EVENT_INVITATEFRIEND_RECALL_NAK::OTHERZONE_FRIEND); }