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
@@ -32,6 +32,7 @@
#include "NPCPackets.h"
#include "PetPackets.h"
#include "QueryPackets.h"
#include "QuestPackets.h"
#include "TotemPackets.h"
#include "WorldStatePackets.h"
@@ -0,0 +1,126 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "QuestPackets.h"
WorldPacket const* WorldPackets::Quest::QuestUpdateComplete::Write()
{
_worldPacket << QuestId;
return &_worldPacket;
}
WorldPacket const* WorldPackets::Quest::QuestGiverQuestComplete::Write()
{
_worldPacket << QuestId;
_worldPacket << Experience;
_worldPacket << RewardMoney;
_worldPacket << RewardHonor;
_worldPacket << RewardTalents;
_worldPacket << RewardArena;
return &_worldPacket;
}
WorldPacket const* WorldPackets::Quest::QuestGiverQuestFailed::Write()
{
_worldPacket << QuestId;
_worldPacket << FailureReason;
return &_worldPacket;
}
WorldPacket const* WorldPackets::Quest::QuestUpdateFailedTimer::Write()
{
_worldPacket << QuestId;
return &_worldPacket;
}
WorldPacket const* WorldPackets::Quest::QuestGiverQuestInvalid::Write()
{
_worldPacket << FailureReason;
return &_worldPacket;
}
WorldPacket const* WorldPackets::Quest::QuestConfirmAccept::Write()
{
_worldPacket << QuestId;
_worldPacket << QuestTitle;
_worldPacket << PlayerGuid;
return &_worldPacket;
}
WorldPacket const* WorldPackets::Quest::QuestPushResult::Write()
{
_worldPacket << PlayerGuid;
_worldPacket << QuestShareMessage;
return &_worldPacket;
}
WorldPacket const* WorldPackets::Quest::QuestUpdateAddKill::Write()
{
_worldPacket << QuestId;
_worldPacket << CreatureEntry;
_worldPacket << CurrentCount;
_worldPacket << RequiredCount;
_worldPacket << ObjectiveGuid;
return &_worldPacket;
}
WorldPacket const* WorldPackets::Quest::QuestUpdateAddPvPKill::Write()
{
_worldPacket << QuestId;
_worldPacket << CurrentCount;
_worldPacket << RequiredCount;
return &_worldPacket;
}
void WorldPackets::Quest::QuestPushResultClient::Read()
{
_worldPacket >> PlayerGuid;
_worldPacket >> QuestId;
uint8 Message;
_worldPacket >> Message;
QuestShareMessage = static_cast<QuestShareMessages>(Message);
}
void WorldPackets::Quest::QuestLogSwapQuest::Read()
{
_worldPacket >> Slot1;
_worldPacket >> Slot2;
}
void WorldPackets::Quest::QuestLogRemoveQuest::Read()
{
_worldPacket >> Slot;
}
void WorldPackets::Quest::QuestConfirmAcceptClient::Read()
{
_worldPacket >> QuestId;
}
void WorldPackets::Quest::PushQuestToParty::Read()
{
_worldPacket >> QuestId;
}
@@ -0,0 +1,214 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef QuestPackets_h__
#define QuestPackets_h__
#include "ObjectGuid.h"
#include "Packet.h"
#include "QuestDef.h"
namespace WorldPackets
{
namespace Quest
{
class QuestLogFull final : public ServerPacket
{
public:
QuestLogFull() : ServerPacket(SMSG_QUESTLOG_FULL, 0) {}
WorldPacket const* Write() override { return &_worldPacket; }
};
class QuestUpdateComplete final : public ServerPacket
{
public:
QuestUpdateComplete() : ServerPacket(SMSG_QUESTUPDATE_COMPLETE, 4) {}
WorldPacket const* Write() override;
uint32 QuestId = 0;
};
class QuestGiverQuestComplete final : public ServerPacket
{
public:
QuestGiverQuestComplete() : ServerPacket(SMSG_QUESTGIVER_QUEST_COMPLETE, 4 + 4 + 4 + 4 + 4 + 4) {}
WorldPacket const* Write() override;
uint32 QuestId = 0;
uint32 Experience = 0;
uint32 RewardMoney = 0;
uint32 RewardHonor = 0;
uint32 RewardTalents = 0;
uint32 RewardArena = 0;
};
class QuestGiverQuestFailed final : public ServerPacket
{
public:
QuestGiverQuestFailed() : ServerPacket(SMSG_QUESTGIVER_QUEST_FAILED, 4 + 4) {}
WorldPacket const* Write() override;
uint32 QuestId = 0;
uint32 FailureReason = 0;
};
class QuestUpdateFailedTimer final : public ServerPacket
{
public:
QuestUpdateFailedTimer() : ServerPacket(SMSG_QUESTUPDATE_FAILEDTIMER, 4) {}
WorldPacket const* Write() override;
uint32 QuestId = 0;
};
class QuestGiverQuestInvalid final : public ServerPacket
{
public:
QuestGiverQuestInvalid() : ServerPacket(SMSG_QUESTGIVER_QUEST_INVALID, 4) {}
WorldPacket const* Write() override;
QuestFailedReason FailureReason = INVALIDREASON_DONT_HAVE_REQ;
};
class QuestConfirmAccept final : public ServerPacket
{
public:
// 4 (QuestId) + title (variable, 16 reserved estimate) + 8 (GUID)
QuestConfirmAccept() : ServerPacket(SMSG_QUEST_CONFIRM_ACCEPT, 4 + 16 + 8) {}
WorldPacket const* Write() override;
uint32 QuestId = 0;
std::string_view QuestTitle = "";
ObjectGuid PlayerGuid;
};
class QuestPushResult final : public ServerPacket
{
public:
QuestPushResult() : ServerPacket(MSG_QUEST_PUSH_RESULT, 8 + 1) {}
WorldPacket const* Write() override;
ObjectGuid PlayerGuid;
QuestShareMessages QuestShareMessage = QUEST_PARTY_MSG_SHARING_QUEST; // valid values: 0-10
};
class QuestUpdateAddItem final : public ServerPacket
{
public:
QuestUpdateAddItem() : ServerPacket(SMSG_QUESTUPDATE_ADD_ITEM, 0) {}
WorldPacket const* Write() override { return &_worldPacket; }
};
class QuestUpdateAddKill final : public ServerPacket
{
public:
QuestUpdateAddKill() : ServerPacket(SMSG_QUESTUPDATE_ADD_KILL, 4 * 4 + 8) {}
WorldPacket const* Write() override;
uint32 QuestId = 0;
uint32 CreatureEntry = 0;
uint32 CurrentCount = 0;
uint32 RequiredCount = 0;
ObjectGuid ObjectiveGuid;
};
class QuestUpdateAddPvPKill final : public ServerPacket
{
public:
QuestUpdateAddPvPKill() : ServerPacket(SMSG_QUESTUPDATE_ADD_PVP_KILL, 3 * 4) {}
WorldPacket const* Write() override;
uint32 QuestId = 0;
uint32 CurrentCount = 0;
uint32 RequiredCount = 0;
};
class QuestPushResultClient final : public ClientPacket
{
public:
QuestPushResultClient(WorldPacket&& packet) : ClientPacket(MSG_QUEST_PUSH_RESULT, std::move(packet)) {}
void Read() override;
ObjectGuid PlayerGuid;
uint32 QuestId = 0;
QuestShareMessages QuestShareMessage = QUEST_PARTY_MSG_SHARING_QUEST;
};
class QuestGiverQuestAutoLaunch final : public ClientPacket
{
public:
QuestGiverQuestAutoLaunch(WorldPacket&& packet) : ClientPacket(CMSG_QUESTGIVER_QUEST_AUTOLAUNCH, std::move(packet)) {}
void Read() override {}
};
class QuestLogSwapQuest final : public ClientPacket
{
public:
QuestLogSwapQuest(WorldPacket&& packet) : ClientPacket(CMSG_QUESTLOG_SWAP_QUEST, std::move(packet)) {}
void Read() override;
uint8 Slot1 = 0;
uint8 Slot2 = 0;
};
class QuestLogRemoveQuest final : public ClientPacket
{
public:
QuestLogRemoveQuest(WorldPacket&& packet) : ClientPacket(CMSG_QUESTLOG_REMOVE_QUEST, std::move(packet)) {}
void Read() override;
uint8 Slot = 0;
};
class QuestConfirmAcceptClient final : public ClientPacket
{
public:
QuestConfirmAcceptClient(WorldPacket&& packet) : ClientPacket(CMSG_QUEST_CONFIRM_ACCEPT, std::move(packet)) {}
void Read() override;
uint32 QuestId = 0;
};
class PushQuestToParty final : public ClientPacket
{
public:
PushQuestToParty(WorldPacket&& packet) : ClientPacket(CMSG_PUSHQUESTTOPARTY, std::move(packet)) {}
void Read() override;
uint32 QuestId = 0;
};
}
}
#endif // QuestPackets_h__
+16 -6
View File
@@ -192,6 +192,16 @@ namespace WorldPackets
class ItemRefund;
}
namespace Quest
{
class QuestPushResultClient;
class QuestGiverQuestAutoLaunch;
class QuestLogSwapQuest;
class QuestLogRemoveQuest;
class QuestConfirmAcceptClient;
class PushQuestToParty;
}
namespace Calendar
{
class GetEvent;
@@ -915,13 +925,13 @@ public: // opcodes handlers
void HandleQuestgiverRequestRewardOpcode(WorldPacket& recvPacket);
void HandleQuestQueryOpcode(WorldPacket& recvPacket);
void HandleQuestgiverCancel(WorldPacket& recvData);
void HandleQuestLogSwapQuest(WorldPacket& recvData);
void HandleQuestLogRemoveQuest(WorldPacket& recvData);
void HandleQuestConfirmAccept(WorldPacket& recvData);
void HandleQuestLogSwapQuest(WorldPackets::Quest::QuestLogSwapQuest& packet);
void HandleQuestLogRemoveQuest(WorldPackets::Quest::QuestLogRemoveQuest& packet);
void HandleQuestConfirmAccept(WorldPackets::Quest::QuestConfirmAcceptClient& packet);
void HandleQuestgiverCompleteQuest(WorldPacket& recvData);
void HandleQuestgiverQuestAutoLaunch(WorldPacket& recvPacket);
void HandlePushQuestToParty(WorldPacket& recvPacket);
void HandleQuestPushResult(WorldPacket& recvPacket);
void HandleQuestgiverQuestAutoLaunch(WorldPackets::Quest::QuestGiverQuestAutoLaunch& packet);
void HandlePushQuestToParty(WorldPackets::Quest::PushQuestToParty& packet);
void HandleQuestPushResult(WorldPackets::Quest::QuestPushResultClient& packet);
void HandleMessagechatOpcode(WorldPacket& recvPacket);
void SendPlayerNotFoundNotice(std::string const& name);