diff options
Diffstat (limited to 'src/server/game/Handlers/QuestHandler.cpp')
| -rw-r--r-- | src/server/game/Handlers/QuestHandler.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index 6bcb4f29a0b..9590356f3dd 100644 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -26,6 +26,7 @@ #include "GossipDef.h" #include "Group.h" #include "Log.h" +#include "LootMgr.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "Player.h" @@ -252,26 +253,31 @@ void WorldSession::HandleQuestQueryOpcode(WorldPackets::Quest::QueryQuestInfo& p void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPackets::Quest::QuestGiverChooseReward& packet) { - TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_CHOOSE_REWARD npc = %s, quest = %u, reward = %u", packet.QuestGiverGUID.ToString().c_str(), packet.QuestID, packet.ItemChoiceID); + TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_CHOOSE_REWARD npc = %s, quest = %u, reward = %u", + packet.QuestGiverGUID.ToString().c_str(), packet.QuestID, packet.Choice.Item.ItemID); Quest const* quest = sObjectMgr->GetQuestTemplate(packet.QuestID); if (!quest) return; - // This is Real Item Entry, not slot id as pre 5.x - if (packet.ItemChoiceID) + // TODO: currency choice items + if (packet.Choice.LootItemType != LootItemType::Item) + return; + + if (packet.Choice.Item.ItemID) { - ItemTemplate const* rewardProto = sObjectMgr->GetItemTemplate(packet.ItemChoiceID); + ItemTemplate const* rewardProto = sObjectMgr->GetItemTemplate(packet.Choice.Item.ItemID); if (!rewardProto) { - TC_LOG_ERROR("entities.player.cheat", "Error in CMSG_QUESTGIVER_CHOOSE_REWARD: player %s (%s) tried to get invalid reward item (Item Entry: %u) for quest %u (possible packet-hacking detected)", _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), packet.ItemChoiceID, packet.QuestID); + TC_LOG_ERROR("entities.player.cheat", "Error in CMSG_QUESTGIVER_CHOOSE_REWARD: player %s (%s) tried to get invalid reward item (Item Entry: %u) for quest %u (possible packet-hacking detected)", + _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), packet.Choice.Item.ItemID, packet.QuestID); return; } bool itemValid = false; for (uint32 i = 0; i < quest->GetRewChoiceItemsCount(); ++i) { - if (quest->RewardChoiceItemId[i] && quest->RewardChoiceItemId[i] == uint32(packet.ItemChoiceID)) + if (quest->RewardChoiceItemId[i] && quest->RewardChoiceItemId[i] == packet.Choice.Item.ItemID) { itemValid = true; break; @@ -284,7 +290,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPackets::Quest::Quest { for (QuestPackageItemEntry const* questPackageItem : *questPackageItems) { - if (questPackageItem->ItemID != packet.ItemChoiceID) + if (questPackageItem->ItemID != packet.Choice.Item.ItemID) continue; if (_player->CanSelectQuestPackageItem(questPackageItem)) @@ -301,7 +307,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPackets::Quest::Quest { for (QuestPackageItemEntry const* questPackageItem : *questPackageItems) { - if (questPackageItem->ItemID != packet.ItemChoiceID) + if (questPackageItem->ItemID != packet.Choice.Item.ItemID) continue; itemValid = true; @@ -313,7 +319,8 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPackets::Quest::Quest if (!itemValid) { - TC_LOG_ERROR("entities.player.cheat", "Error in CMSG_QUESTGIVER_CHOOSE_REWARD: player %s (%s) tried to get reward item (Item Entry: %u) wich is not a reward for quest %u (possible packet-hacking detected)", _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), packet.ItemChoiceID, packet.QuestID); + TC_LOG_ERROR("entities.player.cheat", "Error in CMSG_QUESTGIVER_CHOOSE_REWARD: player %s (%s) tried to get reward item (Item Entry: %u) wich is not a reward for quest %u (possible packet-hacking detected)", + _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), packet.Choice.Item.ItemID, packet.QuestID); return; } } @@ -339,9 +346,9 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPackets::Quest::Quest return; } - if (_player->CanRewardQuest(quest, packet.ItemChoiceID, true)) + if (_player->CanRewardQuest(quest, packet.Choice.Item.ItemID, true)) { - _player->RewardQuest(quest, packet.ItemChoiceID, object); + _player->RewardQuest(quest, packet.Choice.Item.ItemID, object); switch (object->GetTypeId()) { @@ -364,7 +371,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPackets::Quest::Quest } _player->PlayerTalkClass->ClearMenus(); - creatureQGiver->GetAI()->QuestReward(_player, quest, packet.ItemChoiceID); + creatureQGiver->GetAI()->QuestReward(_player, quest, packet.Choice.LootItemType, packet.Choice.Item.ItemID); break; } case TYPEID_GAMEOBJECT: @@ -384,7 +391,7 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPackets::Quest::Quest } _player->PlayerTalkClass->ClearMenus(); - questGiver->AI()->QuestReward(_player, quest, packet.ItemChoiceID); + questGiver->AI()->QuestReward(_player, quest, packet.Choice.LootItemType, packet.Choice.Item.ItemID); break; } default: |
