Merge remote-tracking branch 'upstream/master' into karazhan

This commit is contained in:
crow
2025-09-12 08:41:10 -05:00
6 changed files with 48 additions and 18 deletions

View File

@@ -40,6 +40,7 @@
#include "StatsWeightCalculator.h"
#include "World.h"
#include "AiObjectContext.h"
#include "ItemPackets.h"
const uint64 diveMask = (1LL << 7) | (1LL << 44) | (1LL << 37) | (1LL << 38) | (1LL << 26) | (1LL << 30) | (1LL << 27) |
(1LL << 33) | (1LL << 24) | (1LL << 34);
@@ -1899,7 +1900,9 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool second_chance)
WorldPacket packet(CMSG_AUTOSTORE_BAG_ITEM, 3);
packet << bagIndex << slot << dstBag;
bot->GetSession()->HandleAutoStoreBagItemOpcode(packet);
WorldPackets::Item::AutoStoreBagItem nicePacket(std::move(packet));
nicePacket.Read();
bot->GetSession()->HandleAutoStoreBagItemOpcode(nicePacket);
}
oldItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot);

View File

@@ -4,6 +4,7 @@
*/
#include "EquipAction.h"
#include <utility>
#include "Event.h"
#include "ItemCountValue.h"
@@ -11,6 +12,7 @@
#include "ItemVisitors.h"
#include "Playerbots.h"
#include "StatsWeightCalculator.h"
#include "ItemPackets.h"
bool EquipAction::Execute(Event event)
{
@@ -104,7 +106,10 @@ void EquipAction::EquipItem(Item* item)
WorldPacket packet(CMSG_AUTOEQUIP_ITEM_SLOT, 2);
ObjectGuid itemguid = item->GetGUID();
packet << itemguid << uint8(EQUIPMENT_SLOT_RANGED);
bot->GetSession()->HandleAutoEquipItemSlotOpcode(packet);
WorldPackets::Item::AutoEquipItemSlot nicePacket(std::move(packet));
nicePacket.Read();
bot->GetSession()->HandleAutoEquipItemSlotOpcode(nicePacket);
std::ostringstream out;
out << "Equipping " << chat->FormatItem(itemProto) << " in ranged slot";
@@ -199,7 +204,9 @@ void EquipAction::EquipItem(Item* item)
WorldPacket eqPacket(CMSG_AUTOEQUIP_ITEM_SLOT, 2);
ObjectGuid newItemGuid = item->GetGUID();
eqPacket << newItemGuid << uint8(EQUIPMENT_SLOT_MAINHAND);
bot->GetSession()->HandleAutoEquipItemSlotOpcode(eqPacket);
WorldPackets::Item::AutoEquipItemSlot nicePacket(std::move(eqPacket));
nicePacket.Read();
bot->GetSession()->HandleAutoEquipItemSlotOpcode(nicePacket);
}
// Try moving old main hand weapon to offhand if beneficial
@@ -210,7 +217,9 @@ void EquipAction::EquipItem(Item* item)
WorldPacket offhandPacket(CMSG_AUTOEQUIP_ITEM_SLOT, 2);
ObjectGuid oldMHGuid = mainHandItem->GetGUID();
offhandPacket << oldMHGuid << uint8(EQUIPMENT_SLOT_OFFHAND);
bot->GetSession()->HandleAutoEquipItemSlotOpcode(offhandPacket);
WorldPackets::Item::AutoEquipItemSlot nicePacket(std::move(offhandPacket));
nicePacket.Read();
bot->GetSession()->HandleAutoEquipItemSlotOpcode(nicePacket);
std::ostringstream moveMsg;
moveMsg << "Main hand upgrade found. Moving " << chat->FormatItem(oldMHProto) << " to offhand";
@@ -230,7 +239,9 @@ void EquipAction::EquipItem(Item* item)
WorldPacket eqPacket(CMSG_AUTOEQUIP_ITEM_SLOT, 2);
ObjectGuid newItemGuid = item->GetGUID();
eqPacket << newItemGuid << uint8(EQUIPMENT_SLOT_OFFHAND);
bot->GetSession()->HandleAutoEquipItemSlotOpcode(eqPacket);
WorldPackets::Item::AutoEquipItemSlot nicePacket(std::move(eqPacket));
nicePacket.Read();
bot->GetSession()->HandleAutoEquipItemSlotOpcode(nicePacket);
std::ostringstream out;
out << "Equipping " << chat->FormatItem(itemProto) << " in offhand";
@@ -287,7 +298,9 @@ void EquipAction::EquipItem(Item* item)
WorldPacket packet(CMSG_AUTOEQUIP_ITEM_SLOT, 2);
ObjectGuid itemguid = item->GetGUID();
packet << itemguid << dstSlot;
bot->GetSession()->HandleAutoEquipItemSlotOpcode(packet);
WorldPackets::Item::AutoEquipItemSlot nicePacket(std::move(packet));
nicePacket.Read();
bot->GetSession()->HandleAutoEquipItemSlotOpcode(nicePacket);
}
}

View File

@@ -8,6 +8,7 @@
#include "Event.h"
#include "ItemVisitors.h"
#include "Playerbots.h"
#include "ItemPackets.h"
bool OutfitAction::Execute(Event event)
{
@@ -70,7 +71,9 @@ bool OutfitAction::Execute(Event event)
WorldPacket packet(CMSG_AUTOSTORE_BAG_ITEM, 3);
packet << bagIndex << slot << dstBag;
bot->GetSession()->HandleAutoStoreBagItemOpcode(packet);
WorldPackets::Item::AutoStoreBagItem nicePacket(std::move(packet));
nicePacket.Read();
bot->GetSession()->HandleAutoStoreBagItemOpcode(nicePacket);
}
EquipItems(outfit);

View File

@@ -9,6 +9,7 @@
#include "ItemUsageValue.h"
#include "ItemVisitors.h"
#include "Playerbots.h"
#include "ItemPackets.h"
class SellItemsVisitor : public IterateItemsVisitor
{
@@ -114,9 +115,12 @@ void SellAction::Sell(Item* item)
uint32 botMoney = bot->GetMoney();
WorldPacket p;
WorldPacket p(CMSG_SELL_ITEM);
p << vendorguid << itemguid << count;
bot->GetSession()->HandleSellItemOpcode(p);
WorldPackets::Item::SellItem nicePacket(std::move(p));
nicePacket.Read();
bot->GetSession()->HandleSellItemOpcode(nicePacket);
if (botAI->HasCheat(BotCheatMask::gold))
{

View File

@@ -8,6 +8,8 @@
#include "Event.h"
#include "ItemCountValue.h"
#include "Playerbots.h"
#include "WorldSession.h"
#include "ItemPackets.h"
std::vector<std::string> split(std::string const s, char delim);
@@ -70,7 +72,9 @@ void UnequipAction::UnequipItem(Item* item)
WorldPacket packet(CMSG_AUTOSTORE_BAG_ITEM, 3);
packet << bagIndex << slot << dstBag;
bot->GetSession()->HandleAutoStoreBagItemOpcode(packet);
WorldPackets::Item::AutoStoreBagItem nicePacket(std::move(packet));
nicePacket.Read();
bot->GetSession()->HandleAutoStoreBagItemOpcode(nicePacket);
std::ostringstream out;
out << chat->FormatItem(item->GetTemplate()) << " unequipped";

View File

@@ -9,6 +9,7 @@
#include "Event.h"
#include "ItemUsageValue.h"
#include "Playerbots.h"
#include "ItemPackets.h"
bool UseItemAction::Execute(Event event)
{
@@ -324,8 +325,8 @@ void UseItemAction::TellConsumableUse(Item* item, std::string const action, floa
bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
{
WorldPacket* const packet = new WorldPacket(CMSG_SOCKET_GEMS);
*packet << item->GetGUID();
WorldPacket packet(CMSG_SOCKET_GEMS);
packet << item->GetGUID();
bool fits = false;
for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS;
@@ -337,14 +338,14 @@ bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
{
if (fits)
{
*packet << ObjectGuid::Empty;
packet << ObjectGuid::Empty;
continue;
}
uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(enchant_slot));
if (!enchant_id)
{
*packet << gem->GetGUID();
packet << gem->GetGUID();
fits = true;
continue;
}
@@ -352,20 +353,20 @@ bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
if (!enchantEntry || !enchantEntry->GemID)
{
*packet << gem->GetGUID();
packet << gem->GetGUID();
fits = true;
continue;
}
if (replace && enchantEntry->GemID != gem->GetTemplate()->ItemId)
{
*packet << gem->GetGUID();
packet << gem->GetGUID();
fits = true;
continue;
}
}
*packet << ObjectGuid::Empty;
packet << ObjectGuid::Empty;
}
if (fits)
@@ -375,7 +376,9 @@ bool UseItemAction::SocketItem(Item* item, Item* gem, bool replace)
out << " with " << chat->FormatItem(gem->GetTemplate());
botAI->TellMaster(out);
bot->GetSession()->HandleSocketOpcode(*packet);
WorldPackets::Item::SocketGems nicePacket(std::move(packet));
nicePacket.Read();
bot->GetSession()->HandleSocketOpcode(nicePacket);
}
return fits;