"""Read the 70532 ItemSparse.db2 (WDC5, sparse) into dicts keyed by the hotfixes.item_sparse column names, and RandPropPoints.db2. ItemSparse records: five inline zero-terminated strings (Description, Display3, Display2, Display1, Display), then the fixed fields in the order of ItemSparseLoadInfo (src/server/game/DataStores/DB2LoadInfo.h). Only section 0 holds records; the other sections are single placeholder records. """ import struct STRINGS = ['Description', 'Display3', 'Display2', 'Display1', 'Display'] FIELDS = ([('ExpansionID', 'i'), ('DmgVariance', 'f'), ('LimitCategory', 'i'), ('DurationInInventory', 'i'), ('QualityModifier', 'f'), ('BagFamily', 'i'), ('StartQuestID', 'i'), ('LanguageID', 'i'), ('ItemRange', 'f')] + [('StatPercentageOfSocket%d' % i, 'f') for i in range(1, 11)] + [('StatPercentEditor%d' % i, 'i') for i in range(1, 11)] + [('StatModifierBonusStat%d' % i, 'i') for i in range(1, 11)] + [(n, 'i') for n in ('Stackable', 'MaxCount', 'MinReputation', 'RequiredAbility', 'AllowableRace1', 'AllowableRace2', 'SellPrice', 'BuyPrice', 'VendorStackCount')] + [('PriceVariance', 'f'), ('PriceRandomValue', 'f')] + [(n, 'i') for n in ('Flags1', 'Flags2', 'Flags3', 'Flags4', 'Flags5', 'FactionRelated', 'ModifiedCraftingReagentItemID', 'ContentTuningID', 'PlayerLevelToItemLevelCurveID', 'ItemLevelOffsetCurveID', 'ItemLevelOffsetItemLevel', 'ItemSquishEraID')] + [(n, 'H') for n in ('ItemNameDescriptionID', 'RequiredTransmogHoliday', 'RequiredHoliday', 'GemProperties', 'SocketMatchEnchantmentId', 'TotemCategoryID', 'InstanceBound', 'ZoneBound1', 'ZoneBound2', 'ItemSet', 'LockID', 'PageID', 'ItemDelay', 'MinFactionID', 'RequiredSkillRank', 'RequiredSkill', 'ItemLevel')] + [('AllowableClass', 'h')] + [(n, 'B') for n in ('ArtifactID', 'SpellWeight', 'SpellWeightCategory', 'SocketType1', 'SocketType2', 'SocketType3', 'SheatheType', 'Material', 'PageMaterialID', 'Bonding', 'DamageDamageType', 'ContainerSlots', 'RequiredPVPMedal')] + [('RequiredPVPRank', 'b'), ('RequiredLevel', 'b')] + [(n, 'B') for n in ('InventoryType', 'OverallQualityID', 'AmmunitionType')]) FMT = '<' + ''.join(t for _, t in FIELDS) COLUMNS = ['ID'] + STRINGS + [n for n, _ in FIELDS] def _header(d): H = 136 sc, = struct.unpack_from('= 1 << 15 else v s32 = lambda v: v - (1 << 32) if v >= 1 << 31 else v effects, _ = wdc5.read(effect_path) links, _ = wdc5.read(x_path) out = {} for _, (effect_id, item_id) in links.items(): e = effects.get(effect_id) if e is None or item_id is None: continue out.setdefault(item_id, []).append({ 'ID': effect_id, 'LegacySlotIndex': e[0], 'TriggerType': e[1], 'Charges': s16(e[2]), 'CoolDownMSec': s32(e[3]), 'CategoryCoolDownMSec': s32(e[4]), 'SpellCategoryID': e[5] & 0xFFFF, 'SpellID': s32(e[6])}) return out