From c8289ada7f7d31a5e608c932db71ee6ec7fce0e6 Mon Sep 17 00:00:00 2001 From: Wyrserth Date: Mon, 1 Jul 2019 01:19:31 +0200 Subject: Core/Quest: do not send SMSG_QUESTGIVER_OFFER_REWARD right after SMSG_QUESTGIVER_QUEST_FAILED. Allows the gossip window to close after the client receives a quest failed error (for example: not enough inventory space to store the reward). --- src/server/game/Entities/Player/Player.cpp | 4 -- src/server/game/Handlers/QuestHandler.cpp | 75 ++++++++++++++++-------------- 2 files changed, 39 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 4827b11df62..5d8e814a566 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -14888,10 +14888,6 @@ void Player::AddQuestAndCheckCompletion(Quest const* quest, Object* questGiver) bool Player::CanRewardQuest(Quest const* quest, uint32 reward, bool msg) { - // prevent receive reward with quest items in bank or for not completed quest - if (!CanRewardQuest(quest, msg)) - return false; - ItemPosCountVec dest; if (quest->GetRewChoiceItemsCount() > 0) { diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index 952a084e4cf..4891523037b 100644 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -295,54 +295,57 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket& recvData) _player->GetName().c_str(), _player->GetGUID().GetCounter(), questId); return; } - if (_player->CanRewardQuest(quest, reward, true)) + if (_player->CanRewardQuest(quest, true)) // First, check if player is allowed to turn the quest in (all objectives completed). If not, we send players to the offer reward screen { - _player->RewardQuest(quest, reward, object); - - switch (object->GetTypeId()) + if (_player->CanRewardQuest(quest, reward, true)) // Then check if player can receive the reward item (if inventory is not full, if player doesn't have too many unique items, and so on). If not, the client will close the gossip window { - case TYPEID_UNIT: + _player->RewardQuest(quest, reward, object); + + switch (object->GetTypeId()) { - Creature* questgiver = object->ToCreature(); - // Send next quest - if (Quest const* nextQuest = _player->GetNextQuest(guid, quest)) + case TYPEID_UNIT: { - // Only send the quest to the player if the conditions are met - if (_player->CanTakeQuest(nextQuest, false)) + Creature* questgiver = object->ToCreature(); + // Send next quest + if (Quest const* nextQuest = _player->GetNextQuest(guid, quest)) { - if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true)) - _player->AddQuestAndCheckCompletion(nextQuest, object); - - _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, guid, true); + // Only send the quest to the player if the conditions are met + if (_player->CanTakeQuest(nextQuest, false)) + { + if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true)) + _player->AddQuestAndCheckCompletion(nextQuest, object); + + _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, guid, true); + } } - } - _player->PlayerTalkClass->ClearMenus(); - questgiver->AI()->QuestReward(_player, quest, reward); - break; - } - case TYPEID_GAMEOBJECT: - { - GameObject* questGiver = object->ToGameObject(); - // Send next quest - if (Quest const* nextQuest = _player->GetNextQuest(guid, quest)) + _player->PlayerTalkClass->ClearMenus(); + questgiver->AI()->QuestReward(_player, quest, reward); + break; + } + case TYPEID_GAMEOBJECT: { - // Only send the quest to the player if the conditions are met - if (_player->CanTakeQuest(nextQuest, false)) + GameObject* questGiver = object->ToGameObject(); + // Send next quest + if (Quest const* nextQuest = _player->GetNextQuest(guid, quest)) { - if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true)) - _player->AddQuestAndCheckCompletion(nextQuest, object); - - _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, guid, true); + // Only send the quest to the player if the conditions are met + if (_player->CanTakeQuest(nextQuest, false)) + { + if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true)) + _player->AddQuestAndCheckCompletion(nextQuest, object); + + _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, guid, true); + } } - } - _player->PlayerTalkClass->ClearMenus(); - questGiver->AI()->QuestReward(_player, quest, reward); - break; + _player->PlayerTalkClass->ClearMenus(); + questGiver->AI()->QuestReward(_player, quest, reward); + break; + } + default: + break; } - default: - break; } } else -- cgit v1.2.3