diff --git a/CHANGELOG.md b/CHANGELOG.md index 80b4f549..ea1ac02f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Fixed Research Sync applying progress of a previous techology level to the level on the controller when it's the active research during instance startup. - Fixed data export with a mod using shorthand notation for the default value of a color-setting causing the ModPack data to be set to invalid data. - Fixed per user per instance player stats not being deleted when the instance it's for is deleted. +- Fixed mods setting the item prototype icons property to an object mapping instead of an array breaking the data export. ## Version 2.0.0-alpha.16 diff --git a/packages/host/src/export.ts b/packages/host/src/export.ts index 337a89f5..530f8fc9 100644 --- a/packages/host/src/export.ts +++ b/packages/host/src/export.ts @@ -245,6 +245,18 @@ async function loadLayeredIcon( return icon; } +function fixIcons(item: ItemPrototype) { + const icons = item.icons; + if (typeof icons === "object" && !(icons instanceof Array) && icons !== null) { + // It's possible to specify icons as an object with arbitrary keys + // and the game will still accept it, cast the value to array if + // this is the case. + item = { ...item }; + item.icons = Object.values(icons); + } + return item; +} + const itemTypes = new Set([ "item", "ammo", @@ -277,7 +289,8 @@ const itemTypes = new Set([ function filterItems(prototypes: Prototypes): ItemPrototype[] { return Object.entries(prototypes) .filter(([type, _]) => itemTypes.has(type)) - .flatMap(([_, typePrototypes]) => Object.values(typePrototypes)) as ItemPrototype[] + .flatMap(([_, typePrototypes]) => Object.values(typePrototypes) as ItemPrototype[]) + .map(fixIcons) ; }