fix: auto-detect CharSections.dbc layout and add Blood Elf/Draenei NPC voices

CharSections.dbc has different field layouts between stock WotLK (textures
at field 4-6) and Classic/TBC/Turtle/HD-textured WotLK (VariationIndex at
field 4). Add detectCharSectionsFields() that probes field-4 values at
runtime to determine the correct layout, so both stock and modded clients
work without JSON changes.

Also add BLOODELF_MALE/FEMALE and DRAENEI_MALE/FEMALE voice types to the
NPC voice system — previously all Blood Elf and Draenei NPCs fell through
to GENERIC (random dwarf/gnome/night elf/orc mix).
This commit is contained in:
Kelsi 2026-03-23 11:00:49 -07:00
parent d873f27070
commit 503f9ed650
7 changed files with 242 additions and 87 deletions

View file

@ -38,6 +38,10 @@ enum class VoiceType {
GNOME_FEMALE,
GOBLIN_MALE,
GOBLIN_FEMALE,
BLOODELF_MALE,
BLOODELF_FEMALE,
DRAENEI_MALE,
DRAENEI_FEMALE,
GENERIC, // Fallback
};

View file

@ -57,5 +57,40 @@ inline uint32_t dbcField(const std::string& dbcName, const std::string& fieldNam
return fm ? fm->field(fieldName) : 0xFFFFFFFF;
}
// Forward declaration
class DBCFile;
/**
* Resolved CharSections.dbc field indices.
*
* Stock WotLK 3.3.5a uses: Texture1=4, Texture2=5, Texture3=6, Flags=7,
* VariationIndex=8, ColorIndex=9 (textures first).
* Classic/TBC/Turtle and HD-texture WotLK use: VariationIndex=4, ColorIndex=5,
* Texture1=6, Texture2=7, Texture3=8, Flags=9 (variation first).
*
* detectCharSectionsFields() auto-detects which layout the actual DBC uses
* by sampling field-4 values: small integers (0-15) => variation-first,
* large values (string offsets) => texture-first.
*/
struct CharSectionsFields {
uint32_t raceId = 1;
uint32_t sexId = 2;
uint32_t baseSection = 3;
uint32_t variationIndex = 4;
uint32_t colorIndex = 5;
uint32_t texture1 = 6;
uint32_t texture2 = 7;
uint32_t texture3 = 8;
uint32_t flags = 9;
};
/**
* Detect the actual CharSections.dbc field layout by probing record data.
* @param dbc Loaded CharSections.dbc file (must not be null).
* @param csL JSON-derived field map (may be null defaults used).
* @return Resolved field indices for this particular DBC binary.
*/
CharSectionsFields detectCharSectionsFields(const DBCFile* dbc, const DBCFieldMap* csL);
} // namespace pipeline
} // namespace wowee