XCOM 2
Project DollHouse
[bug] Repro included - Localization not detected for certain modded parts
I've found a minimal repro for the bug some people have reported, where a part falls back to a default "PartType #" name with PD enabled, but localization on the same part works fine in vanilla. It's based on WOTC Sci-Fi Body Suits, which introduces two torso parts, one of which suffers this bug and the other does not.

I edited that mod to reduce these files down to just these lines:

XComContent.ini:
[XComGame.X2BodyPartTemplateManager] +BodyPartTemplateConfig=(PartType="Torso", DLCName="WOTC_Sci_Fi_Body_Suits", TemplateName="CNV_MEA_Body_Suit_M_Torso", ArchetypeName="Kexx_MEA_Suits_GD.ARC_MEA_Body_Suit_Male_Torso", Gender=eGender_Male, bVeteran=false, ArmorTemplate="KevlarArmor", CharacterTemplate="Soldier") +BodyPartTemplateConfig=(PartType="Torso", DLCName="WOTC_Sci_Fi_Body_Suits", TemplateName="MPW_MEA_Body_Suit_M_Torso_Reaper", ArchetypeName="Kexx_MEA_Suits_GD.ARC_MEA_Body_Suit_Male_Torso", Gender=eGender_Male, bVeteran=false, ArmorTemplate="PoweredReaperArmor", CharacterTemplate="ReaperSoldier") +BodyPartTemplateConfig=(PartType="Torso", DLCName="WOTC_Sci_Fi_Body_Suits", TemplateName="CNV_Nanosuit_M_Torso", ArchetypeName="Kexx_Nanosuits_GD.ARC_Nanosuit_Male_Torso", Gender=eGender_Male, bVeteran=false, ArmorTemplate="KevlarArmor", CharacterTemplate="Soldier") +BodyPartTemplateConfig=(PartType="Torso", DLCName="WOTC_Sci_Fi_Body_Suits", TemplateName="MPW_Nanosuit_M_Torso_Reaper", ArchetypeName="Kexx_Nanosuits_GD.ARC_Nanosuit_Male_Torso", Gender=eGender_Male, bVeteran=false, ArmorTemplate="PoweredReaperArmor", CharacterTemplate="ReaperSoldier")

XComGame.int:
[CNV_MEA_Body_Suit_M_Torso X2BodyPartTemplate] DisplayName="ME:A Hyperguardian Torso" [CNV_Nanosuit_M_Torso X2BodyPartTemplate] DisplayName="Nanosuit Torso"

Note that the Reaper armor localizations are missing. This is a bug in that mod, but PD handles it in an unexpected way.

When you view the torso options for a male XCOM soldier with UC enabled, the options are listed as "ME:A Hyperguardian Torso" and "Torso 1". When you disable UC, both options appear with their correct labels. It seems that the version of Kexx_Nanosuits_GD.ARC_Nanosuit_Male_Torso which appears in the list is actually the Reaper version, not the XCOM version. I confirmed this by adding some localizations for the Reaper armors:

[MPW_MEA_Body_Suit_M_Torso_Reaper X2BodyPartTemplate] DisplayName="MPW_MEA_Body_Suit_M_Torso_Reaper" [MPW_Nanosuit_M_Torso_Reaper X2BodyPartTemplate] DisplayName="MPW_Nanosuit_M_Torso_Reaper"

When viewing torso options for a male XCOM soldier with UC enabled, the Nanosuit now appears under the name "MPW_Nanosuit_M_Torso_Reaper".

This behavior is sensitive to the contents of the display string. I changed the display names of the XCOM versions as follows:

[CNV_MEA_Body_Suit_M_Torso X2BodyPartTemplate] DisplayName="CNV_MEA_Body_Suit_M_Torso" [CNV_Nanosuit_M_Torso X2BodyPartTemplate] DisplayName="CNV_Nanosuit_M_Torso"

This resulted in the correct names being displayed for the XCOM soldier: "CNV_MEA_Body_Suit_M_Torso" and "CNV_Nanosuit_M_Torso". I'm guessing somewhere these strings are being hashed, and the hash result dictates which version of an archetype is chosen for display in the list. This could also explain why the bug occurs for one torso and not the other, even though they are configured identically.

A guess at the root cause: PD iterates through a collection to find any one instance of an archetype, with either first-one-wins or last-one-wins behavior, but the order of collection elements is arbitrary (maybe a dictionary).

If that is the cause, a suitable fix may be to find a "best match" within the archetype, first trying to match TemplateName, then ArmorTemplate, then CharacterTemplate. This won't resolve the underlying bug in the other mod, but it will make PD's behavior a little more consistent. It will probably also make the other mod's bug a little less intrusive – missing localizations like this are more likely to crop up in armor types people view less often, such as a male Reaper with powered armor.
Last edited by Malnormalulo; Jan 2 @ 11:33am