diff --git a/src/server/game/Server/Packets/TransmogrificationPackets.h b/src/server/game/Server/Packets/TransmogrificationPackets.h index d72aca8f96..a799509b72 100644 --- a/src/server/game/Server/Packets/TransmogrificationPackets.h +++ b/src/server/game/Server/Packets/TransmogrificationPackets.h @@ -159,12 +159,19 @@ namespace WorldPackets class TransmogOutfitUpdateSlots final : public ClientPacket { public: + enum + { + // Classic 1.60 sends every outfit slot and slot option: 45 (15 TransmogOutfitSlotInfo rows, 42 TransmogOutfitSlotOption + // rows). Retail sent at most 30, and a larger list was refused whole, so armor changes never saved. + MAX_TRANSMOG_OUTFIT_SLOTS = 45 + }; + explicit TransmogOutfitUpdateSlots(WorldPacket&& packet) : ClientPacket(CMSG_TRANSMOG_OUTFIT_UPDATE_SLOTS, std::move(packet)) { } void Read() override; uint32 OutfitID = 0; - Array Slots; + Array Slots; ObjectGuid Npc; uint64 Cost = 0; bool UseAvailableDiscount = false; diff --git a/src/server/game/Transmog/TransmogMgr.cpp b/src/server/game/Transmog/TransmogMgr.cpp index 1b994051cc..7b75e8527e 100644 --- a/src/server/game/Transmog/TransmogMgr.cpp +++ b/src/server/game/Transmog/TransmogMgr.cpp @@ -18,6 +18,7 @@ #include "TransmogMgr.h" #include "DB2Stores.h" #include "FlatSet.h" +#include "Log.h" #include "MapUtils.h" #include "ObjectMgr.h" #include "Player.h" @@ -265,6 +266,13 @@ void TransmogMgr::Load() for (TransmogSituationEntry const* transmogSituation : sTransmogSituationStore) if (transmogSituation->HasFlag(TransmogSituationFlags::DefaultsToOn)) DefaultSituations.push_back(transmogSituation); + + // The client sends one entry per slot and slot option when an outfit is saved; a list longer than the packet allows is + // refused whole, so a client with more slots than this needs MAX_TRANSMOG_OUTFIT_SLOTS raised. + if (AllSlots.size() > WorldPackets::Transmogrification::TransmogOutfitUpdateSlots::MAX_TRANSMOG_OUTFIT_SLOTS) + TC_LOG_ERROR("server.loading", "TransmogOutfitSlotInfo.db2 and TransmogOutfitSlotOption.db2 give {} outfit slots, but " + "CMSG_TRANSMOG_OUTFIT_UPDATE_SLOTS accepts {}: outfits with every slot cannot be saved.", + AllSlots.size(), uint32(WorldPackets::Transmogrification::TransmogOutfitUpdateSlots::MAX_TRANSMOG_OUTFIT_SLOTS)); } ItemModifiedAppearanceEntry const* TransmogMgr::GetItemModifiedAppearance(uint32 itemId, uint32 appearanceModId) diff --git a/tests/game/TransmogOutfitSlotsLayout.cpp b/tests/game/TransmogOutfitSlotsLayout.cpp new file mode 100644 index 0000000000..e93ee99567 --- /dev/null +++ b/tests/game/TransmogOutfitSlotsLayout.cpp @@ -0,0 +1,63 @@ +#include "tc_catch2.h" +#include "TransmogrificationPackets.h" +#include "Util.h" + +// CMSG_TRANSMOG_OUTFIT_UPDATE_SLOTS from the classic 1.60 client: it sends every outfit slot and slot option, 45 entries +// (TransmogOutfitSlotInfo 15 rows, TransmogOutfitSlotOption 42 rows). The packet took at most 30, so every outfit save was +// refused whole and armor changes never stuck (player reports 2026-11-13). +namespace +{ +WorldPacket MakeUpdateSlots(uint32 outfitId, ObjectGuid const& npc, uint64 cost, uint32 count, bool discount) +{ + WorldPacket raw(CMSG_TRANSMOG_OUTFIT_UPDATE_SLOTS); + raw << uint32(outfitId); + raw << uint32(count); + raw << npc; + raw << uint64(cost); + for (uint32 i = 0; i < count; ++i) + { + // written in reverse slot order: Read() sorts by slot and option + uint32 const n = count - 1 - i; + raw << int8(n / 4); // Slot + raw << uint8(n % 4); // SlotOption + raw << uint8(0); // SheatheCategory + raw << uint32(1000 + n); // ItemModifiedAppearanceID + raw << uint8(1); // AppearanceDisplayType + raw << uint32(0); // SpellItemEnchantmentID + raw << uint8(0); // IllusionDisplayType + raw << uint32(0); // Flags + } + raw.WriteBit(discount); + raw.FlushBits(); + return raw; +} +} + +TEST_CASE("TRANSMOG_OUTFIT_UPDATE_SLOTS reads all 45 classic outfit slots", "[TransmogOutfitSlotsLayout]") +{ + ObjectGuid const npc = ObjectGuid::Create(0, 4974, UI64LIT(30001234)); + + WorldPackets::Transmogrification::TransmogOutfitUpdateSlots packet(MakeUpdateSlots(7, npc, 210, 45, true)); + packet.Read(); + + CHECK(packet.OutfitID == 7); + CHECK(packet.Npc == npc); + CHECK(packet.Cost == 210); + CHECK(packet.UseAvailableDiscount); + REQUIRE(packet.Slots.size() == 45); + for (uint32 n = 0; n < 45; ++n) + { + CHECK(AsUnderlyingType(packet.Slots[n].Slot) == int8(n / 4)); + CHECK(AsUnderlyingType(packet.Slots[n].SlotOption) == uint8(n % 4)); + CHECK(packet.Slots[n].ItemModifiedAppearanceID == 1000 + n); + } + CHECK(packet.GetRawPacket()->rpos() == packet.GetRawPacket()->size()); +} + +TEST_CASE("TRANSMOG_OUTFIT_UPDATE_SLOTS still refuses more slots than the client has", "[TransmogOutfitSlotsLayout]") +{ + ObjectGuid const npc = ObjectGuid::Create(0, 4974, UI64LIT(30001234)); + + WorldPackets::Transmogrification::TransmogOutfitUpdateSlots packet(MakeUpdateSlots(7, npc, 0, 46, false)); + CHECK_THROWS(packet.Read()); +}