Performance-Fish icon indicating copy to clipboard operation
Performance-Fish copied to clipboard

Apparent incompatibility with Medical Tab mod

Open morphine00 opened this issue 1 year ago • 3 comments

Hi there, and thanks for Performance Fish!

I've found an apparent incompatibility with Medical Tab.

When you open the medical tab and hover over a pawn's % stat:

  • You can't see the pop-up with info about which upgrades are affecting the stat
  • Left- or right-click to see the available medical operations.

morphine00 avatar May 23 '24 22:05 morphine00

This is because Medical Tab used BestThingRequest.singleDef. Performance-Fish used an UNSAFE patch, which will use that member as a placeholder for a HashSet ThingFilter.allowedDefs IN SOME RARE CASES which I can't find in vanilla. Then the HashSet SHOULD be used in ListerThings patch.

However Medical Tab will be the rare case. And it uses BestThingRequest.singleDef directly bypassing ListerThings patch so wrong type and boom. Before this unsafe patch is changed to a safe one you should disable ThingFilterPatches.BestThingRequest.

Foxtr0t1337 avatar Jun 19 '24 08:06 Foxtr0t1337

@Foxtr0t1337 if you'd like to discuss implementation details of patches, especially regarding safety concerns, please DM me on discord. My username is bradson there.

The patch is designed to replace singleDef for requests that return multiple defs, where singleDef is expected to be null and direct derefencing of it would be throwing NREs without fish. These requests are intended to be used for rimworld's various listers, which store references to things and keep them organized by ThingRequest. Medical Tab is instead misusing it to access a filter's defs, and compares against null to check for validity. The correct vanilla way to access a filter's defs is to use filter.AllowedDefs or filter.AnyAllowedDef, without additional detours through requests.

Obviously fish causes the error here as it's causing singleDef to not be null where it normally would be. Workarounds such as adding another field to the request or replacing the def with a valid def that medical tab recognizes as invalid on another check can be implemented

bbradson avatar Jun 19 '24 13:06 bbradson

Other viable approaches are patching medical tab's use of thing requests or directly getting it fixed there. It only affects that mod after all

bbradson avatar Jun 19 '24 13:06 bbradson