neitsa / PrepareLanding

PrepareLanding: a Rimworld Mod
MIT License
20 stars 9 forks source link

Animals can graze now filter problem #7

Closed neitsa closed 7 years ago

neitsa commented 7 years ago

This filter seems to be used even when not specifically asked for. There might also be some quirks about preset saves.

From steam comments [user QuakeIV]:

I have been tyring to filter for extreme-cold conditions, and it will kill off all of the tiles it finds with a 'can graze now' filter. I cannot find or disable this filer, please help?

2nd comment:

Uh, quick updoot, it seems to work fine except when saving and loading. (if you save then the same issues manifest as if you had loaded). Coastal tiles goes from ~ to being checked when you save or load a profile for cold weathers, and then it will check for 'cangrazenow' and generally remove all of the results.

In other words, its usable for finding super cold embarks, but not with the save profiles.

From steam user Ozymandias:

Regarding coastal tiles with saved presets: I can't say if it's not saved properly, or if the default value isn't properly initialized, but adding the filter (from the easy_start example) in the XML with state Partial works.

As for the hidden AnimalsCanGrazeNow filter, I don't know what to do in order to keep all tiles (I usually end up with only 1 to 3 tiles), and removing the filter from the XML doesn't prevent the filtering. Since changing the starting season, in the advanced menu of the world gen, will change the 'can graze' state (and thus the number of filtered tiles), maybe this filter should be removed altogether.

neitsa commented 7 years ago

Bug was easy to spot... While loading a preset, in LoadThreeState (code) method: if there is no corresponding preset entry, the default behavior was to return default(MultiCheckboxState):

return xChild == null ? default(MultiCheckboxState) : LoadEnum<MultiCheckboxState>(xChild, StateNode);

The problem is that default(MultiCheckboxState) returns MultiCheckboxState.On and not MultiCheckboxState.Partial.

Patch is to return Partial state by default:

        // note: if xChild is null do NOT return default(MultiCheckboxState) because the default state will be ON!
        return xChild == null ? MultiCheckboxState.Partial : LoadEnum<MultiCheckboxState>(xChild, StateNode);