remove bad opcode cause mem leak

This commit is contained in:
luis
2026-11-13 05:51:57 -03:00
parent 0fa0fa9723
commit fe3a8eb6ec
5 changed files with 2 additions and 159 deletions
-106
View File
@@ -940,112 +940,6 @@ void WorldSession::HandleSpawnTrackingUpdate(WorldPackets::Quest::SpawnTrackingU
SendPacket(response.Write());
}
void WorldSession::HandleQueryQuestItemUsability(WorldPackets::Quest::QueryQuestItemUsability& packet)
{
if (!_player)
return;
Creature* creature = ObjectAccessor::GetCreature(*_player, packet.CreatureGUID);
if (!creature)
return;
uint32 creatureEntry = creature->GetEntry();
WorldPackets::Quest::QuestItemUsabilityResponse response;
response.CreatureGUID = packet.CreatureGUID;
for (ObjectGuid const& itemGuid : packet.ItemGUIDs)
{
Item const* item = _player->GetItemByGuid(itemGuid);
if (!item)
{
response.ItemsData.emplace_back(itemGuid, false);
continue;
}
ItemTemplate const* itemTemplate = item->GetTemplate();
if (!itemTemplate)
{
response.ItemsData.emplace_back(itemGuid, false);
continue;
}
bool isUsable = false;
auto bounds = sObjectMgr->GetSpellClickInfoMapBounds(creatureEntry);
for (auto const& [npcEntry, spellClickInfo] : bounds)
{
uint32 spellClickSpellId = spellClickInfo.spellId;
for (auto const* effect : itemTemplate->Effects)
{
if (!effect || effect->SpellID == 0)
continue;
if (uint32(effect->SpellID) == spellClickSpellId)
{
isUsable = true;
break;
}
}
if (isUsable)
break;
}
if (!isUsable)
{
uint32 itemId = item->GetEntry();
for (auto const& [questId, statusData] : _player->m_QuestStatus)
{
if (statusData.Status != QUEST_STATUS_INCOMPLETE)
continue;
Quest const* quest = sObjectMgr->GetQuestTemplate(questId);
if (!quest)
continue;
if (quest->GetSrcItemId() != itemId)
continue;
for (QuestObjective const& obj : quest->GetObjectives())
{
if (obj.Type == QUEST_OBJECTIVE_MONSTER)
{
uint32 objectiveCreature = uint32(std::abs(obj.ObjectID));
if (objectiveCreature == creatureEntry)
{
isUsable = true;
break;
}
// Else quest have trigger or script, check linking killcredit
CreatureTemplate const* cTemplate = creature->GetCreatureTemplate();
if (cTemplate)
{
for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i)
{
if (cTemplate->KillCredit[i] == objectiveCreature && cTemplate->KillCredit[i] != 0)
{
isUsable = true;
break;
}
}
}
if (isUsable)
break;
}
}
if (isUsable)
break;
}
}
response.ItemsData.emplace_back(itemGuid, isUsable);
}
SendPacket(response.Write());
}
void WorldSession::HandleCloseQuestChoice(WorldPackets::Quest::CloseQuestChoice& /*closeQuestChoice*/)
{
// Client notification that player closed quest choice UI - no server action needed
@@ -951,33 +951,6 @@ namespace WorldPackets::Quest
return &_worldPacket;
}
void QueryQuestItemUsability::Read()
{
_worldPacket >> CreatureGUID;
uint32 count;
_worldPacket >> count;
ItemGUIDs.resize(count);
for (uint32 i = 0; i < count; ++i)
_worldPacket >> ItemGUIDs[i];
}
WorldPacket const* QuestItemUsabilityResponse::Write()
{
_worldPacket << CreatureGUID;
_worldPacket << Size<uint32>(ItemsData);
_worldPacket << Size<uint32>(ItemsData);
for (auto const& pair : ItemsData)
_worldPacket << pair.first;
for (auto const& pair : ItemsData)
_worldPacket.WriteBit(pair.second);
_worldPacket.FlushBits();
return &_worldPacket;
}
WorldPacket const* DisplayQuestPopup::Write()
{
_worldPacket << int32(QuestID);
@@ -894,28 +894,6 @@ namespace WorldPackets
// Quest Enhancement Packets
// ============================================================
class QueryQuestItemUsability final : public ClientPacket
{
public:
explicit QueryQuestItemUsability(WorldPacket&& packet) : ClientPacket(CMSG_QUERY_QUEST_ITEM_USABILITY, std::move(packet)) {}
void Read() override;
ObjectGuid CreatureGUID;
std::vector<ObjectGuid> ItemGUIDs;
};
class QuestItemUsabilityResponse final : public ServerPacket
{
public:
explicit QuestItemUsabilityResponse() : ServerPacket(SMSG_QUEST_ITEM_USABILITY_RESPONSE, 24) {}
WorldPacket const* Write() override;
ObjectGuid CreatureGUID;
std::vector<std::pair<ObjectGuid, bool>> ItemsData;
};
class CloseQuestChoice final : public ClientPacket
{
public:
+2 -2
View File
@@ -903,7 +903,7 @@ void OpcodeTable::InitializeClientOpcodes()
DEFINE_HANDLER(CMSG_QUERY_PLAYER_NAME_BY_COMMUNITY_ID, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::Handle_NULL);
DEFINE_HANDLER(CMSG_QUERY_QUEST_COMPLETION_NPCS, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleQueryQuestCompletionNPCs);
DEFINE_HANDLER(CMSG_QUERY_QUEST_INFO, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleQuestQueryOpcode);
DEFINE_HANDLER(CMSG_QUERY_QUEST_ITEM_USABILITY, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleQueryQuestItemUsability);
DEFINE_HANDLER(CMSG_QUERY_QUEST_ITEM_USABILITY, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::Handle_NULL);
DEFINE_HANDLER(CMSG_QUERY_REALM_NAME, STATUS_AUTHED, PROCESS_INPLACE, &WorldSession::HandleQueryRealmName);
DEFINE_HANDLER(CMSG_QUERY_SCENARIO_POI, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleQueryScenarioPOI);
DEFINE_HANDLER(CMSG_QUERY_SELECTED_WOW_LABS_AREA, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL);
@@ -2274,7 +2274,7 @@ void OpcodeTable::InitializeServerOpcodes()
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUEST_GIVER_REQUEST_ITEMS, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUEST_GIVER_STATUS, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUEST_GIVER_STATUS_MULTIPLE, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUEST_ITEM_USABILITY_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUEST_ITEM_USABILITY_RESPONSE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUEST_LOG_FULL, STATUS_NEVER, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUEST_NON_LOG_UPDATE_COMPLETE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUEST_POI_QUERY_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_REALM);
-2
View File
@@ -1060,7 +1060,6 @@ namespace WorldPackets
namespace Quest
{
class QuestConfirmAccept;
class QueryQuestItemUsability;
class CloseQuestChoice;
class QuestGiverStatusQuery;
class QuestGiverStatusMultipleQuery;
@@ -2298,7 +2297,6 @@ public:
void HandleRafClaimNextReward(WorldPackets::RaF::RafClaimNextReward& packet);
void HandleQueryTreasurePicker(WorldPackets::Query::QueryTreasurePicker const& queryTreasurePicker);
void HandleSpawnTrackingUpdate(WorldPackets::Quest::SpawnTrackingUpdate& spawnTrackingUpdate);
void HandleQueryQuestItemUsability(WorldPackets::Quest::QueryQuestItemUsability& queryQuestItemUsability);
void HandleCloseQuestChoice(WorldPackets::Quest::CloseQuestChoice& packet);
void HandleRequestScheduledAreaPoiUpdate(WorldPackets::Quest::RequestScheduledAreaPoiUpdate& packet);
void HandleHideQuestChoice(WorldPackets::Quest::HideQuestChoice& hideQuestChoice);