diff --git a/game/04-Variables/variables-versionUpdate.twee b/game/04-Variables/variables-versionUpdate.twee index cd569cffe0558d588bb27d854c8da1be85c4db8a..4541bb3ecaff471ce650b81593a9aa1e921e0517 100644 --- a/game/04-Variables/variables-versionUpdate.twee +++ b/game/04-Variables/variables-versionUpdate.twee @@ -3576,9 +3576,9 @@ /* Code that should not be moved into a check like above */ <<set $runWardrobeSanityChecker to true>> - <<if $objectVersion.updateClothes lt 36 or $objectVersion.updateClothes is undefined>> + <<if $objectVersion.updateClothes lt 37 or $objectVersion.updateClothes is undefined>> <<updateClothes>> - <<set $objectVersion.updateClothes to 36>> + <<set $objectVersion.updateClothes to 37>> <!--If you have added any `colour_combat` or `accessory_colour_combat` to clothes that need their `colour` or `accessory_colour`, this will clear them. Remove `colour_combat` or `accessory_colour_combat` where this is the case, they are independant so `colour_combat` will only clear `colour`--> <</if>> @@ -4424,42 +4424,6 @@ <<set $real_transformationParts.traits.flaunting to "disabled">> <</if>> <</if>> - - <<for _garmentLayer range ["upper", "lower", "under_upper", "under_lower", "over_upper", "over_lower"]>> - <<set $_indexTemp to $worn[_garmentLayer].index>> - - <<if _garmentLayer.includes("upper")>> - - /*Worn*/ - <<if $worn[_garmentLayer].outfitPrimary and Object.values($worn[_garmentLayer].outfitPrimary) isnot "broken" and Object.values($worn[_garmentLayer].outfitPrimary) isnot setup.clothes[_garmentLayer][$_indexTemp].outfitPrimary>> - <<set $worn[_garmentLayer].outfitPrimary to clone(setup.clothes[_garmentLayer][$worn[_garmentLayer].index].outfitPrimary)>> - <</if>> - - /*wardrobe */ - <<for $_wardrobeOption to 0; _wardrobeOption < $wardrobe[_garmentLayer].length; _wardrobeOption++>> - <<if $wardrobe[_garmentLayer][_wardrobeOption].outfitPrimary and $wardrobe[_garmentLayer][_wardrobeOption].outfitPrimary isnot "broken" and $wardrobe[_garmentLayer][_wardrobeOption].outfitPrimary isnot setup.clothes[_garmentLayer][$_indexTemp].outfitPrimary>> - <<set $wardrobe[_garmentLayer][_wardrobeOption].outfitPrimary to clone(setup.clothes[_garmentLayer][$_indexTemp].outfitPrimary)>> - <</if>> - <</for>> - - <<elseif _garmentLayer.includes("lower")>> - - /*Worn*/ - <<if $worn[_garmentLayer].outfitSecondary and $worn[_garmentLayer].outfitSecondary[1] isnot "broken" and $worn[_garmentLayer].outfitSecondary[1] isnot setup.clothes[_garmentLayer][$_indexTemp].outfitSecondary[1]>> - <<set $worn[_garmentLayer].outfitSecondary to clone(setup.clothes[_garmentLayer][$_indexTemp].outfitSecondary)>> - <</if>> - - /*wardrobe */ - <<for $_wardrobeOption to 0; _wardrobeOption < $wardrobe[_garmentLayer].length; _wardrobeOption++>> - <<if $wardrobe[_garmentLayer][_wardrobeOption].outfitSecondary and $wardrobe[_garmentLayer][_wardrobeOption].outfitSecondary[1] isnot "broken" and $wardrobe[_garmentLayer][_wardrobeOption].outfitSecondary[1] isnot setup.clothes[_garmentLayer][$_indexTemp].outfitSecondary[1]>> - <<set $wardrobe[_garmentLayer][_wardrobeOption].outfitSecondary to clone(setup.clothes[_garmentLayer][$_indexTemp].outfitSecondary)>> - <</if>> - <</for>> - - <</if>> - <</for>> - - <<unset _garmentLayer>> <!-- V0.4.0.5 Old saves with untyped named NPCs --> <<if $NPCName[0].type is undefined>> diff --git a/game/base-clothing/updateClothes.js b/game/base-clothing/updateClothes.js index 1b6925fb2b21be1125da42a8af5b0b93c4b0c9f1..dffe9c3db9c0f67d3b2c2d97b455988d5446062a 100644 --- a/game/base-clothing/updateClothes.js +++ b/game/base-clothing/updateClothes.js @@ -97,18 +97,20 @@ function updateClothesItem(slot, item) { if (skip.includes(key)) continue; if (key === "hoodposition" && V.objectVersion.updateClothes >= 31) continue; if (key === "outfitPrimary") { - if (item[key] === undefined && itemRef[key] !== undefined) { - item[key] = clone(itemRef[key]); - if (item.one_piece === "broken") { - if (slot === "upper") item[key].lower = "broken"; - else if (slot === "under_upper") item[key].under_lower = "broken"; + if (itemRef.outfitPrimary !== undefined) { + if (item.outfitPrimary === undefined) item.outfitPrimary = clone(itemRef.outfitPrimary); + for (const k in itemRef.outfitPrimary) { + // if one_piece is broken, everything is broken + if (item.one_piece === "broken") item.outfitPrimary[k] = "broken"; + // if an item is still in one piece, it's safe to regenerate it's value from itemRef + else if (item.outfitPrimary[k] !== "broken") item.outfitPrimary[k] = clone(itemRef.outfitPrimary[k]); } } continue; } if (key === "outfitSecondary") { - if (item[key] === undefined && itemRef[key] !== undefined) { - item[key] = clone(itemRef[key]); + if (itemRef[key] !== undefined) { + if (item[key] === undefined) item[key] = clone(itemRef[key]); if (item.one_piece === "broken") item[key][1] = "broken"; } continue;