fix(v2): pack capacity from enhanced_properties.ItemSlots_Decal

The inventory service doesn't return items_capacity directly — it's
in enhanced_properties.ItemSlots_Decal. Updated normalizer to read
from there. Also defaults to 24 (standard AC pack size) with ||
instead of ?? to catch 0/undefined/null. Removed debug console.logs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-04-12 22:29:46 +02:00
parent 8e77274316
commit bd8ad863d1
3 changed files with 16 additions and 20 deletions

View file

@ -16,7 +16,7 @@ function normalizeItem(raw: any): any {
object_class: raw.object_class ?? raw.ObjectClass ?? 0,
current_wielded_location: raw.current_wielded_location ?? v(raw.CurrentWieldedLocation) ?? v(Number(iv['10'])) ?? 0,
container_id: raw.container_id ?? raw.ContainerId ?? 0,
items_capacity: raw.items_capacity ?? v(raw.ItemsCapacity) ?? v(Number(iv['6'])) ?? undefined,
items_capacity: raw.items_capacity ?? v(raw.ItemsCapacity) ?? v(Number(iv['6'])) ?? raw.enhanced_properties?.ItemSlots_Decal ?? undefined,
value: raw.value ?? v(raw.Value) ?? v(Number(iv['19'])) ?? 0,
burden: raw.burden ?? v(raw.Burden) ?? v(Number(iv['5'])) ?? 0,
armor_level: raw.armor_level ?? v(raw.ArmorLevel),
@ -246,10 +246,6 @@ export const InventoryWindow: React.FC<Props> = ({ id, charName, zIndex }) => {
packItems.get(cid)!.push(item);
}
});
// Debug: log pack mapping
console.log('[INV DEBUG] containers:', containers.map((c: any) => ({ id: c.item_id, name: c.name })));
console.log('[INV DEBUG] packItems keys:', [...packItems.keys()]);
console.log('[INV DEBUG] packItems sizes:', [...packItems.entries()].map(([k, v]) => `${k}: ${v.length}`));
return { equippedMap, containers, packItems };
}, [items]);
@ -344,7 +340,7 @@ export const InventoryWindow: React.FC<Props> = ({ id, charName, zIndex }) => {
const cid = c.item_id;
// Count items directly from normalized items array instead of relying on packItems map
const childCount = items.filter((i: any) => i.container_id === cid && i.item_id !== cid).length;
const cap = c.items_capacity ?? 24;
const cap = c.items_capacity || 24;
const pct = cap > 0 ? Math.min(100, (childCount / cap) * 100) : 0;
return <PackIcon key={cid} iconSrc={`/icons/${iconHex(c.icon)}.png`} isActive={activePack === cid}
fillPct={pct}