mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 16:38:42 +01:00
Core/Player: Keep shared quests through map changes instead of getting stuck in busy state
This commit is contained in:
@@ -411,7 +411,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGU
|
||||
|
||||
WorldPacket data(SMSG_QUESTGIVER_QUEST_DETAILS, 100); // guess size
|
||||
data << uint64(npcGUID);
|
||||
data << uint64(_session->GetPlayer()->GetDivider());
|
||||
data << uint64(_session->GetPlayer()->GetPlayerSharingQuest());
|
||||
data << uint32(quest->GetQuestId());
|
||||
data << questTitle;
|
||||
data << questDetails;
|
||||
|
||||
@@ -23222,6 +23222,14 @@ void Player::SendInitialPacketsAfterAddToMap()
|
||||
}
|
||||
else if (GetRaidDifficulty() != GetStoredRaidDifficulty())
|
||||
SendRaidDifficulty(GetGroup() != NULL);
|
||||
|
||||
if (GetPlayerSharingQuest())
|
||||
{
|
||||
if (Quest const* quest = sObjectMgr->GetQuestTemplate(GetSharedQuestID()))
|
||||
PlayerTalkClass->SendQuestGiverQuestDetails(quest, GetGUID(), true);
|
||||
else
|
||||
ClearQuestSharingInfo();
|
||||
}
|
||||
}
|
||||
|
||||
void Player::SendUpdateToOutOfRangeGroupMembers()
|
||||
|
||||
@@ -1630,8 +1630,10 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
void SendQuestUpdateAddPlayer(Quest const* quest, uint16 oldCount, uint16 addCount);
|
||||
void SendQuestGiverStatusMultiple();
|
||||
|
||||
ObjectGuid GetDivider() const { return m_divider; }
|
||||
void SetDivider(ObjectGuid guid) { m_divider = guid; }
|
||||
uint32 GetSharedQuestID() const { return m_sharedQuestId; }
|
||||
ObjectGuid GetPlayerSharingQuest() const { return m_playerSharingQuest; }
|
||||
void SetQuestSharingInfo(ObjectGuid guid, uint32 id) { m_playerSharingQuest = guid; m_sharedQuestId = id; }
|
||||
void ClearQuestSharingInfo() { m_playerSharingQuest = ObjectGuid::Empty; m_sharedQuestId = 0; }
|
||||
|
||||
uint32 GetInGameTime() const { return m_ingametime; }
|
||||
void SetInGameTime(uint32 time) { m_ingametime = time; }
|
||||
@@ -2572,7 +2574,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
QuestSet m_monthlyquests;
|
||||
SeasonalEventQuestMap m_seasonalquests;
|
||||
|
||||
ObjectGuid m_divider;
|
||||
ObjectGuid m_playerSharingQuest;
|
||||
uint32 m_sharedQuestId;
|
||||
uint32 m_ingametime;
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
@@ -113,29 +113,29 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData)
|
||||
else
|
||||
object = ObjectAccessor::FindPlayer(guid);
|
||||
|
||||
#define CLOSE_GOSSIP_CLEAR_DIVIDER() \
|
||||
#define CLOSE_GOSSIP_CLEAR_SHARING_INFO() \
|
||||
do { \
|
||||
_player->PlayerTalkClass->SendCloseGossip(); \
|
||||
_player->SetDivider(ObjectGuid::Empty); \
|
||||
_player->ClearQuestSharingInfo(); \
|
||||
} while (0)
|
||||
|
||||
// no or incorrect quest giver
|
||||
if (!object)
|
||||
{
|
||||
CLOSE_GOSSIP_CLEAR_DIVIDER();
|
||||
CLOSE_GOSSIP_CLEAR_SHARING_INFO();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Player* playerQuestObject = object->ToPlayer())
|
||||
{
|
||||
if ((_player->GetDivider() && _player->GetDivider() != guid) || !playerQuestObject->CanShareQuest(questId))
|
||||
if ((_player->GetPlayerSharingQuest() && _player->GetPlayerSharingQuest() != guid) || !playerQuestObject->CanShareQuest(questId))
|
||||
{
|
||||
CLOSE_GOSSIP_CLEAR_DIVIDER();
|
||||
CLOSE_GOSSIP_CLEAR_SHARING_INFO();
|
||||
return;
|
||||
}
|
||||
if (!_player->IsInSameRaidWith(playerQuestObject))
|
||||
{
|
||||
CLOSE_GOSSIP_CLEAR_DIVIDER();
|
||||
CLOSE_GOSSIP_CLEAR_SHARING_INFO();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData)
|
||||
{
|
||||
if (!object->hasQuest(questId))
|
||||
{
|
||||
CLOSE_GOSSIP_CLEAR_DIVIDER();
|
||||
CLOSE_GOSSIP_CLEAR_SHARING_INFO();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData)
|
||||
// some kind of WPE protection
|
||||
if (!_player->CanInteractWithQuestGiver(object))
|
||||
{
|
||||
CLOSE_GOSSIP_CLEAR_DIVIDER();
|
||||
CLOSE_GOSSIP_CLEAR_SHARING_INFO();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -160,17 +160,17 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData)
|
||||
// prevent cheating
|
||||
if (!GetPlayer()->CanTakeQuest(quest, true))
|
||||
{
|
||||
CLOSE_GOSSIP_CLEAR_DIVIDER();
|
||||
CLOSE_GOSSIP_CLEAR_SHARING_INFO();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_player->GetDivider().IsEmpty())
|
||||
if (!_player->GetPlayerSharingQuest().IsEmpty())
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayer(_player->GetDivider());
|
||||
Player* player = ObjectAccessor::FindPlayer(_player->GetPlayerSharingQuest());
|
||||
if (player)
|
||||
{
|
||||
player->SendPushToPartyResponse(_player, QUEST_PARTY_MSG_ACCEPT_QUEST);
|
||||
_player->SetDivider(ObjectGuid::Empty);
|
||||
_player->ClearQuestSharingInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData)
|
||||
|
||||
if (player->CanTakeQuest(quest, true))
|
||||
{
|
||||
player->SetDivider(_player->GetGUID());
|
||||
player->SetQuestSharingInfo(_player->GetGUID(), questId);
|
||||
|
||||
// need confirmation that any gossip window will close
|
||||
player->PlayerTalkClass->SendCloseGossip();
|
||||
@@ -211,9 +211,9 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recvData)
|
||||
}
|
||||
}
|
||||
|
||||
CLOSE_GOSSIP_CLEAR_DIVIDER();
|
||||
CLOSE_GOSSIP_CLEAR_SHARING_INFO();
|
||||
|
||||
#undef CLOSE_GOSSIP_CLEAR_DIVIDER
|
||||
#undef CLOSE_GOSSIP_CLEAR_SHARING_INFO
|
||||
}
|
||||
|
||||
void WorldSession::HandleQuestgiverQueryQuestOpcode(WorldPacket& recvData)
|
||||
@@ -473,7 +473,7 @@ void WorldSession::HandleQuestConfirmAccept(WorldPacket& recvData)
|
||||
if (!quest->HasFlag(QUEST_FLAGS_PARTY_ACCEPT))
|
||||
return;
|
||||
|
||||
Player* originalPlayer = ObjectAccessor::FindPlayer(_player->GetDivider());
|
||||
Player* originalPlayer = ObjectAccessor::FindPlayer(_player->GetPlayerSharingQuest());
|
||||
if (!originalPlayer)
|
||||
return;
|
||||
|
||||
@@ -495,7 +495,7 @@ void WorldSession::HandleQuestConfirmAccept(WorldPacket& recvData)
|
||||
}
|
||||
}
|
||||
|
||||
_player->SetDivider(ObjectGuid::Empty);
|
||||
_player->ClearQuestSharingInfo();
|
||||
}
|
||||
|
||||
void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recvData)
|
||||
@@ -621,7 +621,7 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (receiver->GetDivider())
|
||||
if (receiver->GetPlayerSharingQuest())
|
||||
{
|
||||
sender->SendPushToPartyResponse(receiver, QUEST_PARTY_MSG_BUSY);
|
||||
continue;
|
||||
@@ -636,7 +636,7 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
|
||||
receiver->PlayerTalkClass->SendQuestGiverRequestItems(quest, sender->GetGUID(), receiver->CanCompleteRepeatableQuest(quest), true);
|
||||
else
|
||||
{
|
||||
receiver->SetDivider(sender->GetGUID());
|
||||
receiver->SetQuestSharingInfo(sender->GetGUID(), questId);
|
||||
receiver->PlayerTalkClass->SendQuestGiverQuestDetails(quest, receiver->GetGUID(), true);
|
||||
}
|
||||
}
|
||||
@@ -651,9 +651,9 @@ void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket)
|
||||
|
||||
TC_LOG_DEBUG("network", "WORLD: Received MSG_QUEST_PUSH_RESULT");
|
||||
|
||||
if (_player->GetDivider())
|
||||
if (_player->GetPlayerSharingQuest())
|
||||
{
|
||||
if (_player->GetDivider() == guid)
|
||||
if (_player->GetPlayerSharingQuest() == guid)
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayer(_player->GetDivider());
|
||||
if (player)
|
||||
@@ -664,7 +664,7 @@ void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket)
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
}
|
||||
_player->SetDivider(ObjectGuid::Empty);
|
||||
_player->ClearQuestSharingInfo();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user