diff --git a/Data/expansions/tbc/dbc_layouts.json b/Data/expansions/tbc/dbc_layouts.json index e7b33faa..e11682cf 100644 --- a/Data/expansions/tbc/dbc_layouts.json +++ b/Data/expansions/tbc/dbc_layouts.json @@ -119,14 +119,14 @@ "InventoryIcon": 5, "LeftModel": 1, "LeftModelTexture": 3, - "TextureArmLower": 16, - "TextureArmUpper": 15, - "TextureFoot": 22, - "TextureHand": 17, - "TextureLegLower": 21, - "TextureLegUpper": 20, - "TextureTorsoLower": 19, - "TextureTorsoUpper": 18 + "TextureArmLower": 15, + "TextureArmUpper": 14, + "TextureFoot": 21, + "TextureHand": 16, + "TextureLegLower": 20, + "TextureLegUpper": 19, + "TextureTorsoLower": 18, + "TextureTorsoUpper": 17 }, "ItemSet": { "ID": 0, diff --git a/Data/expansions/wotlk/dbc_layouts.json b/Data/expansions/wotlk/dbc_layouts.json index 1657eb2b..e563d2c9 100644 --- a/Data/expansions/wotlk/dbc_layouts.json +++ b/Data/expansions/wotlk/dbc_layouts.json @@ -131,14 +131,14 @@ "InventoryIcon": 5, "LeftModel": 1, "LeftModelTexture": 3, - "TextureArmLower": 16, - "TextureArmUpper": 15, - "TextureFoot": 22, - "TextureHand": 17, - "TextureLegLower": 21, - "TextureLegUpper": 20, - "TextureTorsoLower": 19, - "TextureTorsoUpper": 18 + "TextureArmLower": 15, + "TextureArmUpper": 14, + "TextureFoot": 21, + "TextureHand": 16, + "TextureLegLower": 20, + "TextureLegUpper": 19, + "TextureTorsoLower": 18, + "TextureTorsoUpper": 17 }, "ItemSet": { "ID": 0, diff --git a/include/pipeline/dbc_loader.hpp b/include/pipeline/dbc_loader.hpp index 24d1e756..49f9df63 100644 --- a/include/pipeline/dbc_loader.hpp +++ b/include/pipeline/dbc_loader.hpp @@ -7,6 +7,8 @@ #include #include +#include "pipeline/dbc_layout.hpp" + namespace wowee { namespace pipeline { @@ -149,5 +151,28 @@ private: bool loadCSV(const std::vector& csvData); }; +/** + * Build the 8-element texture region field index array for ItemDisplayInfo.dbc. + * Classic/Turtle 23-field DBCs have textures at 14-21; + * TBC/WotLK 25-field DBCs have textures at 15-22. + * Detects automatically from the loaded DBC's field count. + */ +inline void getItemDisplayInfoTextureFields(const DBCFile& dbc, + const DBCFieldMap* layout, + uint32_t (&out)[8]) +{ + // 25-field DBCs (TBC/WotLK) shift textures +1 vs 23-field (Classic/Turtle) + uint32_t base = (dbc.getFieldCount() >= 25) ? 15u : 14u; + if (layout) { + uint32_t idx = layout->field("TextureArmUpper"); + if (idx != 0xFFFFFFFF) { + base = idx; + // Correct JSON layouts written for 23-field when DBC is actually 25-field + if (base == 14 && dbc.getFieldCount() >= 25) base = 15; + } + } + for (int i = 0; i < 8; i++) out[i] = base + static_cast(i); +} + } // namespace pipeline } // namespace wowee diff --git a/src/core/entity_spawner.cpp b/src/core/entity_spawner.cpp index 58d34402..d8f28e11 100644 --- a/src/core/entity_spawner.cpp +++ b/src/core/entity_spawner.cpp @@ -1076,16 +1076,8 @@ void EntitySpawner::spawnOnlineCreature(uint64_t guid, uint32_t displayId, float }; const auto* idiL = pipeline::getActiveDBCLayout() ? pipeline::getActiveDBCLayout()->getLayout("ItemDisplayInfo") : nullptr; - const uint32_t texRegionFields[8] = { - idiL ? (*idiL)["TextureArmUpper"] : 14u, - idiL ? (*idiL)["TextureArmLower"] : 15u, - idiL ? (*idiL)["TextureHand"] : 16u, - idiL ? (*idiL)["TextureTorsoUpper"]: 17u, - idiL ? (*idiL)["TextureTorsoLower"]: 18u, - idiL ? (*idiL)["TextureLegUpper"] : 19u, - idiL ? (*idiL)["TextureLegLower"] : 20u, - idiL ? (*idiL)["TextureFoot"] : 21u, - }; + uint32_t texRegionFields[8]; + pipeline::getItemDisplayInfoTextureFields(*idiDbc, idiL, texRegionFields); const bool npcIsFemale = (extraCopy.sexId == 1); const bool npcHasArmArmor = (extraCopy.equipDisplayId[7] != 0 || extraCopy.equipDisplayId[8] != 0); @@ -2949,18 +2941,8 @@ void EntitySpawner::setOnlinePlayerEquipment(uint64_t guid, "FootTexture", }; - // Texture component region fields from DBC layout - // Binary DBC (23 fields) has textures at 14+ - const uint32_t texRegionFields[8] = { - idiL ? (*idiL)["TextureArmUpper"] : 14u, - idiL ? (*idiL)["TextureArmLower"] : 15u, - idiL ? (*idiL)["TextureHand"] : 16u, - idiL ? (*idiL)["TextureTorsoUpper"]: 17u, - idiL ? (*idiL)["TextureTorsoLower"]: 18u, - idiL ? (*idiL)["TextureLegUpper"] : 19u, - idiL ? (*idiL)["TextureLegLower"] : 20u, - idiL ? (*idiL)["TextureFoot"] : 21u, - }; + uint32_t texRegionFields[8]; + pipeline::getItemDisplayInfoTextureFields(*displayInfoDbc, idiL, texRegionFields); std::vector> regionLayers; const bool isFemale = (st.genderId == 1); @@ -4038,16 +4020,8 @@ std::vector EntitySpawner::resolveEquipmentTexturePaths(uint64_t gu "TorsoUpperTexture", "TorsoLowerTexture", "LegUpperTexture", "LegLowerTexture", "FootTexture", }; - const uint32_t texRegionFields[8] = { - idiL ? (*idiL)["TextureArmUpper"] : 14u, - idiL ? (*idiL)["TextureArmLower"] : 15u, - idiL ? (*idiL)["TextureHand"] : 16u, - idiL ? (*idiL)["TextureTorsoUpper"]: 17u, - idiL ? (*idiL)["TextureTorsoLower"]: 18u, - idiL ? (*idiL)["TextureLegUpper"] : 19u, - idiL ? (*idiL)["TextureLegLower"] : 20u, - idiL ? (*idiL)["TextureFoot"] : 21u, - }; + uint32_t texRegionFields[8]; + pipeline::getItemDisplayInfoTextureFields(*displayInfoDbc, idiL, texRegionFields); const bool isFemale = (st.genderId == 1); for (int s = 0; s < 19; s++) { diff --git a/src/rendering/character_preview.cpp b/src/rendering/character_preview.cpp index ebdbf13e..7002d397 100644 --- a/src/rendering/character_preview.cpp +++ b/src/rendering/character_preview.cpp @@ -739,16 +739,8 @@ bool CharacterPreview::applyEquipment(const std::vector& eq // Texture component region fields — use DBC layout when available, fall back to binary offsets. const auto* idiL = pipeline::getActiveDBCLayout() ? pipeline::getActiveDBCLayout()->getLayout("ItemDisplayInfo") : nullptr; - const uint32_t texRegionFields[8] = { - idiL ? (*idiL)["TextureArmUpper"] : 14u, - idiL ? (*idiL)["TextureArmLower"] : 15u, - idiL ? (*idiL)["TextureHand"] : 16u, - idiL ? (*idiL)["TextureTorsoUpper"] : 17u, - idiL ? (*idiL)["TextureTorsoLower"] : 18u, - idiL ? (*idiL)["TextureLegUpper"] : 19u, - idiL ? (*idiL)["TextureLegLower"] : 20u, - idiL ? (*idiL)["TextureFoot"] : 21u, - }; + uint32_t texRegionFields[8]; + pipeline::getItemDisplayInfoTextureFields(*displayInfoDbc, idiL, texRegionFields); std::vector> regionLayers; regionLayers.reserve(32); diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index bfd572b5..59d6f03f 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -3910,18 +3910,8 @@ void GameScreen::updateCharacterTextures(game::Inventory& inventory) { if (!displayInfoDbc) return; const auto* idiL = pipeline::getActiveDBCLayout() ? pipeline::getActiveDBCLayout()->getLayout("ItemDisplayInfo") : nullptr; - // Texture component region fields (8 regions: ArmUpper..Foot) - // Binary DBC (23 fields) has textures at 14+ - const uint32_t texRegionFields[8] = { - idiL ? (*idiL)["TextureArmUpper"] : 14u, - idiL ? (*idiL)["TextureArmLower"] : 15u, - idiL ? (*idiL)["TextureHand"] : 16u, - idiL ? (*idiL)["TextureTorsoUpper"]: 17u, - idiL ? (*idiL)["TextureTorsoLower"]: 18u, - idiL ? (*idiL)["TextureLegUpper"] : 19u, - idiL ? (*idiL)["TextureLegLower"] : 20u, - idiL ? (*idiL)["TextureFoot"] : 21u, - }; + uint32_t texRegionFields[8]; + pipeline::getItemDisplayInfoTextureFields(*displayInfoDbc, idiL, texRegionFields); // Collect equipment texture regions from all equipped items std::vector> regionLayers;