[1.1] Conflict between apparelStuffFilter and apparelRequired

Started by SineSwiper, March 01, 2020, 07:52:12 PM

Previous topic - Next topic

SineSwiper

With the new CanUseStuff check within pawnApparelGenerator.GenerateWorkingPossibleApparelSetFor's block for apparelRequired, there arises a certain kind of conflict between FactionDef->apparelStuffFilter and PawnKindDef->apparelRequired->stuffCategories. I discovered this nasty bug while fixing Faction Blender to work with 1.1.

For example, PlayerColony has a "Synthread" apparelStuffFilter. This poses a problem for certain PawnKindDef, like tribals. The Tribal_Berserker requires a War Mask (apparelRequired), and War Masks are only made of Wood. If you try to put a Tribal_Berserker in the starting colonist pool, RimWorld tries to make the required apparel for the new pawn, produces a zero-length list of ThingStuffPairs (because wood isn't synthread), picks nothing, and then tries to add a null pair into its workingSet.

This causes the game to red error, and produce nasty effects like blanking out the "choose your colonist" screen or failing to create a starting map.  While it's the modder's fault for putting the PawnKindDef in a faction with an incompatible apparelStuffFilter, the bug:

1. Produces a rather unhelpful error, which makes the condition hard to pinpoint.
2. Soft crashes the game, map, or loading of a pawn.
3. Worked in 1.0 because the apparelRequired block wasn't as strict and didn't check CanUseStuff.

RimWorld should really be more graceful when it finds conflicts like these and just fallback to a random set within allApparelPairs if there's a conflict (ie: let the guy have his wooden war mask). Or just take away the mask, despite the pawn requirement. Perhaps do this with a warning, to let the modder know that they goofed up and added a bad apparelRequired / apparelStuffFilter combination.