refactor(Core/Packets): Rewrite various quest packets to modern class. (#22835)

Co-authored-by: sudlud <sudlud@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Benjamin Jackson
2026-06-13 15:29:45 -04:00
committed by GitHub
parent 81457d95f2
commit a623dd2383
8 changed files with 458 additions and 129 deletions

View File

@@ -27,6 +27,7 @@
#include "Opcodes.h"
#include "Player.h"
#include "QuestDef.h"
#include "QuestPackets.h"
#include "ScriptMgr.h"
#include "World.h"
#include "WorldPacket.h"
@@ -382,29 +383,23 @@ void WorldSession::HandleQuestgiverCancel(WorldPacket& /*recvData*/)
_player->PlayerTalkClass->SendCloseGossip();
}
void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recvData)
void WorldSession::HandleQuestLogSwapQuest(WorldPackets::Quest::QuestLogSwapQuest& packet)
{
uint8 slot1, slot2;
recvData >> slot1 >> slot2;
if (slot1 == slot2 || slot1 >= MAX_QUEST_LOG_SIZE || slot2 >= MAX_QUEST_LOG_SIZE)
if (packet.Slot1 == packet.Slot2 || packet.Slot1 >= MAX_QUEST_LOG_SIZE || packet.Slot2 >= MAX_QUEST_LOG_SIZE)
return;
LOG_DEBUG("network", "WORLD: Received CMSG_QUESTLOG_SWAP_QUEST slot 1 = {}, slot 2 = {}", slot1, slot2);
LOG_DEBUG("network", "WORLD: Received CMSG_QUESTLOG_SWAP_QUEST slot 1 = {}, slot 2 = {}", packet.Slot1, packet.Slot2);
GetPlayer()->SwapQuestSlot(slot1, slot2);
GetPlayer()->SwapQuestSlot(packet.Slot1, packet.Slot2);
}
void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recvData)
void WorldSession::HandleQuestLogRemoveQuest(WorldPackets::Quest::QuestLogRemoveQuest& packet)
{
uint8 slot;
recvData >> slot;
LOG_DEBUG("network", "WORLD: Received CMSG_QUESTLOG_REMOVE_QUEST slot = {}", packet.Slot);
LOG_DEBUG("network", "WORLD: Received CMSG_QUESTLOG_REMOVE_QUEST slot = {}", slot);
if (slot < MAX_QUEST_LOG_SIZE)
if (packet.Slot < MAX_QUEST_LOG_SIZE)
{
if (uint32 questId = _player->GetQuestSlotQuestId(slot))
if (uint32 questId = _player->GetQuestSlotQuestId(packet.Slot))
{
if (!_player->TakeQuestSourceItem(questId, true))
return; // can't un-equip some items, reject quest cancel
@@ -442,20 +437,17 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recvData)
}
}
_player->SetQuestSlot(slot, 0);
_player->SetQuestSlot(packet.Slot, 0);
_player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED, 1);
}
}
void WorldSession::HandleQuestConfirmAccept(WorldPacket& recvData)
void WorldSession::HandleQuestConfirmAccept(WorldPackets::Quest::QuestConfirmAcceptClient& packet)
{
uint32 questId;
recvData >> questId;
LOG_DEBUG("network", "WORLD: Received CMSG_QUEST_CONFIRM_ACCEPT quest = {}", packet.QuestId);
LOG_DEBUG("network", "WORLD: Received CMSG_QUEST_CONFIRM_ACCEPT quest = {}", questId);
if (Quest const* quest = sObjectMgr->GetQuestTemplate(questId))
if (Quest const* quest = sObjectMgr->GetQuestTemplate(packet.QuestId))
{
if (!quest->HasFlag(QUEST_FLAGS_PARTY_ACCEPT))
return;
@@ -530,21 +522,18 @@ void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recvData)
}
}
void WorldSession::HandleQuestgiverQuestAutoLaunch(WorldPacket& /*recvPacket*/)
void WorldSession::HandleQuestgiverQuestAutoLaunch(WorldPackets::Quest::QuestGiverQuestAutoLaunch& /*packet*/)
{
}
void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
void WorldSession::HandlePushQuestToParty(WorldPackets::Quest::PushQuestToParty& packet)
{
uint32 questId;
recvPacket >> questId;
if (!_player->CanShareQuest(questId))
if (!_player->CanShareQuest(packet.QuestId))
return;
LOG_DEBUG("network", "WORLD: Received CMSG_PUSHQUESTTOPARTY quest = {}", questId);
LOG_DEBUG("network", "WORLD: Received CMSG_PUSHQUESTTOPARTY quest = {}", packet.QuestId);
if (Quest const* quest = sObjectMgr->GetQuestTemplate(questId))
if (Quest const* quest = sObjectMgr->GetQuestTemplate(packet.QuestId))
{
if (Group* group = _player->GetGroup())
{
@@ -561,7 +550,7 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
continue;
}
if (player->GetQuestStatus(questId) == QUEST_STATUS_COMPLETE)
if (player->GetQuestStatus(packet.QuestId) == QUEST_STATUS_COMPLETE)
{
_player->SendPushToPartyResponse(player, QUEST_PARTY_MSG_FINISH_QUEST);
continue;
@@ -613,21 +602,16 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
}
}
void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket)
void WorldSession::HandleQuestPushResult(WorldPackets::Quest::QuestPushResultClient& packet)
{
ObjectGuid guid;
uint32 questId;
uint8 msg;
recvPacket >> guid >> questId >> msg;
if (_player->GetDivider() && _player->GetDivider() == guid)
if (_player->GetDivider() && _player->GetDivider() == packet.PlayerGuid)
{
if (Player* player = ObjectAccessor::GetPlayer(*_player, _player->GetDivider()))
{
WorldPacket data(MSG_QUEST_PUSH_RESULT, 8 + 4 + 1);
data << _player->GetGUID();
data << uint8(msg); // valid values: 0-8
player->SendDirectMessage(&data);
WorldPackets::Quest::QuestPushResult questPushResult;
questPushResult.PlayerGuid = _player->GetGUID();
questPushResult.QuestShareMessage = packet.QuestShareMessage;
player->SendDirectMessage(questPushResult.Write());
_player->SetDivider();
}
}