diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 06cae2ef2..8cedbab74 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -13897,6 +13897,33 @@ void Player::SendCanTakeQuestResponse( uint32 msg ) sLog.outDebug("WORLD: Sent SMSG_QUESTGIVER_QUEST_INVALID"); } +void Player::SendQuestConfirmAccept(const Quest* pQuest, Player* pReceiver) +{ + if (pReceiver) + { + std::string strTitle = pQuest->GetTitle(); + + int loc_idx = pReceiver->GetSession()->GetSessionDbLocaleIndex(); + + if (loc_idx >= 0) + { + if (const QuestLocale* pLocale = objmgr.GetQuestLocale(pQuest->GetQuestId())) + { + if (pLocale->Title.size() > loc_idx && !pLocale->Title[loc_idx].empty()) + strTitle = pLocale->Title[loc_idx]; + } + } + + WorldPacket data(SMSG_QUEST_CONFIRM_ACCEPT, (4 + strTitle.size() + 8)); + data << uint32(pQuest->GetQuestId()); + data << strTitle; + data << uint64(GetGUID()); + pReceiver->GetSession()->SendPacket(&data); + + sLog.outDebug("WORLD: Sent SMSG_QUEST_CONFIRM_ACCEPT"); + } +} + void Player::SendPushToPartyResponse( Player *pPlayer, uint32 msg ) { if( pPlayer ) diff --git a/src/game/Player.h b/src/game/Player.h index 39a25e8f0..78aa5d945 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1369,6 +1369,7 @@ class MANGOS_DLL_SPEC Player : public Unit void SendQuestFailed( uint32 quest_id ); void SendQuestTimerFailed( uint32 quest_id ); void SendCanTakeQuestResponse( uint32 msg ); + void SendQuestConfirmAccept(Quest const* pQuest, Player* pReceiver); void SendPushToPartyResponse( Player *pPlayer, uint32 msg ); void SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count ); void SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, uint64 guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count ); diff --git a/src/game/QuestDef.h b/src/game/QuestDef.h index 999e8de7a..02729db1d 100644 --- a/src/game/QuestDef.h +++ b/src/game/QuestDef.h @@ -120,7 +120,7 @@ enum __QuestFlags { // Flags used at server and sent to client QUEST_FLAGS_STAY_ALIVE = 0x00000001, // Not used currently - QUEST_FLAGS_PARTY_ACCEPT = 0x00000002, // Not used currently. If player in party, all players that can accept this quest will receive confirmation box to accept quest CMSG_QUEST_CONFIRM_ACCEPT/SMSG_QUEST_CONFIRM_ACCEPT + QUEST_FLAGS_PARTY_ACCEPT = 0x00000002, // If player in party, all players that can accept this quest will receive confirmation box to accept quest CMSG_QUEST_CONFIRM_ACCEPT/SMSG_QUEST_CONFIRM_ACCEPT QUEST_FLAGS_EXPLORATION = 0x00000004, // Not used currently QUEST_FLAGS_SHARABLE = 0x00000008, // Can be shared: Player::CanShareQuest() //QUEST_FLAGS_NONE2 = 0x00000010, // Not used currently diff --git a/src/game/QuestHandler.cpp b/src/game/QuestHandler.cpp index 1cef7dd22..5f105b411 100644 --- a/src/game/QuestHandler.cpp +++ b/src/game/QuestHandler.cpp @@ -154,6 +154,30 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data ) { _player->AddQuest( qInfo, pObject ); + if (qInfo->HasFlag(QUEST_FLAGS_PARTY_ACCEPT)) + { + if (Group* pGroup = _player->GetGroup()) + { + for(GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + { + Player* pPlayer = itr->getSource(); + + if (!pPlayer || pPlayer == _player) // not self + continue; + + if (pPlayer->CanTakeQuest(qInfo, true)) + { + pPlayer->SetDivider(_player->GetGUID()); + + //need confirmation that any gossip window will close + pPlayer->PlayerTalkClass->CloseGossip(); + + _player->SendQuestConfirmAccept(qInfo, pPlayer); + } + } + } + } + if ( _player->CanCompleteQuest( quest ) ) _player->CompleteQuest( quest ); @@ -370,7 +394,34 @@ void WorldSession::HandleQuestConfirmAccept(WorldPacket& recv_data) uint32 quest; recv_data >> quest; - sLog.outDebug( "WORLD: Received CMSG_QUEST_CONFIRM_ACCEPT quest = %u",quest ); + sLog.outDebug("WORLD: Received CMSG_QUEST_CONFIRM_ACCEPT quest = %u", quest); + + if (const Quest* pQuest = objmgr.GetQuestTemplate(quest)) + { + if (!pQuest->HasFlag(QUEST_FLAGS_PARTY_ACCEPT)) + return; + + Player* pOriginalPlayer = ObjectAccessor::FindPlayer(_player->GetDivider()); + + if (!pOriginalPlayer) + return; + + if (pQuest->GetType() == QUEST_TYPE_RAID) + { + if (!_player->IsInSameRaidWith(pOriginalPlayer)) + return; + } + else + { + if (!_player->IsInSameGroupWith(pOriginalPlayer)) + return; + } + + if (_player->CanAddQuest(pQuest, true)) + _player->AddQuest(pQuest, NULL); // NULL, this prevent DB script from duplicate running + + _player->SetDivider(0); + } } void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recv_data) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 59d75bd20..f40da81ac 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8645" + #define REVISION_NR "8646" #endif // __REVISION_NR_H__