Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/transmog_scripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,31 +1064,35 @@ class PS_Transmogrification : public PlayerScript
AddToDatabase(player, it);
}

void OnPlayerLootItem(Player* player, Item* item, uint32 /*count*/, ObjectGuid /*lootguid*/) override
void OnPlayerLootItem(Player* /*player*/, Item* /*item*/, uint32 /*count*/, ObjectGuid /*lootguid*/) override
{
if (!sT->GetUseCollectionSystem() || !item || typeid(*item) != typeid(Item))
return;
if (item->GetTemplate()->Bonding == ItemBondingType::BIND_WHEN_PICKED_UP || item->IsSoulBound())
{
AddToDatabase(player, item);
}
// Intentionally left no-op. Other modules (e.g., auto-destroy/sell junk) may delete the item
// during earlier OnPlayerLootItem hooks, making this pointer unsafe to touch.
// Collection is handled in OnPlayerCreateItem and OnPlayerAfterStoreOrEquipNewItem.
return;
}

void OnPlayerCreateItem(Player* player, Item* item, uint32 /*count*/) override
{
if (!sT->GetUseCollectionSystem())
if (!sT->GetUseCollectionSystem() || !item)
return;
if (item->GetTemplate()->Bonding == ItemBondingType::BIND_WHEN_PICKED_UP || item->IsSoulBound())
ItemTemplate const* itemTemplate = item->GetTemplate();
if (!itemTemplate)
return;
if (itemTemplate->Bonding == ItemBondingType::BIND_WHEN_PICKED_UP || item->IsSoulBound())
{
AddToDatabase(player, item);
}
}

void OnPlayerAfterStoreOrEquipNewItem(Player* player, uint32 /*vendorslot*/, Item* item, uint8 /*count*/, uint8 /*bag*/, uint8 /*slot*/, ItemTemplate const* /*pProto*/, Creature* /*pVendor*/, VendorItem const* /*crItem*/, bool /*bStore*/) override
{
if (!sT->GetUseCollectionSystem())
if (!sT->GetUseCollectionSystem() || !item)
return;
ItemTemplate const* itemTemplate = item->GetTemplate();
if (!itemTemplate)
return;
if (item->GetTemplate()->Bonding == ItemBondingType::BIND_WHEN_PICKED_UP || item->IsSoulBound())
if (itemTemplate->Bonding == ItemBondingType::BIND_WHEN_PICKED_UP || item->IsSoulBound())
{
AddToDatabase(player, item);
}
Expand Down