Core/PacketIO: Fixed data sent in SMSG_BUY_FAILED

This commit is contained in:
luis
2026-10-24 20:45:49 -03:00
parent 34b1e445b3
commit 7e4bb2cbda
4 changed files with 37 additions and 37 deletions
+33 -33
View File
@@ -1,18 +1,3 @@
#include "HouseInteriorMap.h"
#include "Housing.h"
#include "HousingDecorEntity.h"
#include "HousingDefines.h"
#include "HousingMap.h"
#include "HousingMgr.h"
#include "HousingMirrorEntity.h"
#include "HousingNeighborhoodMirrorEntity.h"
#include "HousingPackets.h"
#include "HousingPlayerHouseEntity.h"
#include "HousingRoomEntity.h"
#include "InitiativeManager.h"
#include "MeshObject.h"
#include "Neighborhood.h"
#include "NeighborhoodMgr.h"
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
@@ -186,6 +171,21 @@
#include "QuaternionData.h"
#include "LFGPackets.h"
#include "ScriptHelpers.h"
#include "HouseInteriorMap.h"
#include "Housing.h"
#include "HousingDecorEntity.h"
#include "HousingDefines.h"
#include "HousingMap.h"
#include "HousingMgr.h"
#include "HousingMirrorEntity.h"
#include "HousingNeighborhoodMirrorEntity.h"
#include "HousingPackets.h"
#include "HousingPlayerHouseEntity.h"
#include "HousingRoomEntity.h"
#include "InitiativeManager.h"
#include "MeshObject.h"
#include "Neighborhood.h"
#include "NeighborhoodMgr.h"
#include <cmath>
//WowCommunity
@@ -13660,11 +13660,11 @@ void Player::SendEquipError(InventoryResult msg, Item const* item1 /*= nullptr*/
SendDirectMessage(failure.Write());
}
void Player::SendBuyError(BuyResult msg, Creature const* creature, uint32 item) const
void Player::SendBuyError(BuyResult msg, Creature const* creature, uint32 vendorslot) const
{
WorldPackets::Item::BuyFailed packet;
packet.VendorGUID = creature ? creature->GetGUID() : ObjectGuid::Empty;
packet.Muid = item;
packet.Muid = vendorslot + 1;
packet.Reason = msg;
SendDirectMessage(packet.Write());
}
@@ -25537,7 +25537,7 @@ bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorSlot,
CurrencyTypesEntry const* proto = sCurrencyTypesStore.LookupEntry(currency);
if (!proto)
{
SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, currency);
SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, vendorSlot);
return false;
}
@@ -25546,20 +25546,20 @@ bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorSlot,
{
TC_LOG_DEBUG("network", "Player::BuyCurrencyFromVendorSlot: Vendor ({}) not found or player '{}' ({}) can't interact with him.",
vendorGuid.ToString(), GetName(), GetGUID().ToString());
SendBuyError(BUY_ERR_DISTANCE_TOO_FAR, nullptr, currency);
SendBuyError(BUY_ERR_DISTANCE_TOO_FAR, nullptr, vendorSlot);
return false;
}
VendorItemData const* vItems = creature->GetVendorItems();
if (!vItems || vItems->Empty())
{
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, currency);
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, vendorSlot);
return false;
}
if (vendorSlot >= vItems->GetItemCount())
{
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, currency);
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, vendorSlot);
return false;
}
@@ -25624,7 +25624,7 @@ bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorSlot,
CurrencyTypesEntry const* entry = sCurrencyTypesStore.LookupEntry(iece->CurrencyID[i]);
if (!entry)
{
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, currency); // Find correct error
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, vendorSlot); // Find correct error
return false;
}
@@ -25651,7 +25651,7 @@ bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorSlot,
if (iece->MinFactionID && uint32(GetReputationRank(iece->MinFactionID)) < iece->RequiredAchievement)
{
SendBuyError(BUY_ERR_REPUTATION_REQUIRE, creature, currency);
SendBuyError(BUY_ERR_REPUTATION_REQUIRE, creature, vendorSlot);
return false;
}
@@ -25669,7 +25669,7 @@ bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorSlot,
}
else // currencies have no price defined, can only be bought with ExtendedCost
{
SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, currency);
SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, vendorSlot);
return false;
}
@@ -25718,13 +25718,13 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item);
if (!pProto)
{
SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, item);
SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, vendorslot);
return false;
}
if (!(pProto->GetAllowableClass() & GetClassMask()) && pProto->GetBonding() == BIND_ON_ACQUIRE && !IsGameMaster())
{
SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, item);
SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, vendorslot);
return false;
}
@@ -25736,7 +25736,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
{
TC_LOG_DEBUG("network", "Player::BuyItemFromVendorSlot: Vendor ({}) not found or player '{}' ({}) can't interact with him.",
vendorguid.ToString(), GetName(), GetGUID().ToString());
SendBuyError(BUY_ERR_DISTANCE_TOO_FAR, nullptr, item);
SendBuyError(BUY_ERR_DISTANCE_TOO_FAR, nullptr, vendorslot);
return false;
}
@@ -25744,20 +25744,20 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
{
TC_LOG_DEBUG("condition", "Player::BuyItemFromVendorSlot: Player '{}' ({}) doesn't meed conditions for creature (Entry: {}, Item: {})",
GetName(), GetGUID().ToString(), creature->GetEntry(), item);
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, item);
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, vendorslot);
return false;
}
VendorItemData const* vItems = creature->GetVendorItems();
if (!vItems || vItems->Empty())
{
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, item);
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, vendorslot);
return false;
}
if (vendorslot >= vItems->GetItemCount())
{
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, item);
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, vendorslot);
return false;
}
@@ -25765,7 +25765,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
// store diff item (cheating)
if (!crItem || crItem->item != item)
{
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, item);
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, vendorslot);
return false;
}
@@ -25787,7 +25787,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
if (pProto->GetRequiredReputationFaction() && (uint32(GetReputationRank(pProto->GetRequiredReputationFaction())) < pProto->GetRequiredReputationRank()))
{
SendBuyError(BUY_ERR_REPUTATION_REQUIRE, creature, item);
SendBuyError(BUY_ERR_REPUTATION_REQUIRE, creature, vendorslot);
return false;
}
@@ -25894,7 +25894,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
if (!HasEnoughMoney(price))
{
SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, item);
SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, vendorslot);
return false;
}
}
+1 -1
View File
@@ -1735,7 +1735,7 @@ class TC_GAME_API Player final : public Unit, public GridObject<Player>
Item* GetItemFromBuyBackSlot(uint32 slot);
void RemoveItemFromBuyBackSlot(uint32 slot, bool del);
void SendEquipError(InventoryResult msg, Item const* item1 = nullptr, Item const* item2 = nullptr, uint32 itemId = 0) const;
void SendBuyError(BuyResult msg, Creature const* creature, uint32 item) const;
void SendBuyError(BuyResult msg, Creature const* creature, uint32 vendorslot) const;
void SendSellError(SellResult msg, Creature const* creature, ObjectGuid guid) const;
void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; }
void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; }
+1 -1
View File
@@ -510,7 +510,7 @@ void WorldSession::HandleBuybackItem(WorldPackets::Item::BuyBackItem& packet)
uint32 price = _player->m_activePlayerData->BuybackPrice[packet.Slot - BUYBACK_SLOT_START];
if (!_player->HasEnoughMoney(uint64(price)))
{
_player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, pItem->GetEntry());
_player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0);
return;
}
@@ -73,13 +73,13 @@ void WorldSession::HandlePetitionBuy(WorldPackets::Petition::PetitionBuy& packet
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(charterItemID);
if (!pProto)
{
_player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, charterItemID);
_player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, nullptr, 0);
return;
}
if (!_player->HasEnoughMoney(uint64(cost)))
{
_player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, charterItemID);
_player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, 0);
return;
}