RimWorld

RimWorld

Useful Marks
NullReference/IndexOutOfRange in Assets.Reload() when trait label is empty
Details:
When a pawn has a trait with an empty or missing label (e.g. due to translation mods), UsefulMarks.Assets.Reload() throws a System.IndexOutOfRangeException in GenText.CapitalizeFirst() via TraitDegreeData.LabelCap.
Because this happens in the static constructor of Assets, the whole overlay system fails to draw.

Expected:
Skip or safely handle traits with empty labels instead of throwing.

Suggested fix:
In MarkerConditionTrait.Scan(), check for string.IsNullOrEmpty(label) before calling CapitalizeFirst().

Steps to reproduce:

Load UsefulMarks + any translation mod with a TraitDef that has an empty <label> or <degreeDatas.N.label>.

Have a pawn with that trait.

Observe NRE in log and overlay not drawing.

Log excerpt:

System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Verse.GenText.CapitalizeFirst (System.String str)
at RimWorld.TraitDegreeData.get_LabelCap ()
at UsefulMarks.MarkerConditionTrait.Scan ()