GarwelGarwel / Rimocracy

RimWorld mod to add politics to the game
MIT License
1 stars 3 forks source link

Prospective fix for negative time until election bug #77

Closed muppet2011ad closed 1 year ago

muppet2011ad commented 1 year ago

Hi,

I left a comment on the workshop page for the mod a couple days ago about a bug where the time to elections (and as it turns out the time to a decision cancelling) went negative and the election never happened. I have no experience with Rimworld modding but out of curiosity I decided to have a poke around based on this error log: image

So it seems the offending error was being thrown in this enumeration: https://github.com/GarwelGarwel/Rimocracy/blob/cbc2d1c843d813263c4126cb9c9fbf4b6769bd04/Source/Defs/DecisionDef.cs#L204 which boils down to a Where here: https://github.com/GarwelGarwel/Rimocracy/blob/cbc2d1c843d813263c4126cb9c9fbf4b6769bd04/Source/Utility.cs#L68 I have no idea why the PawnsFinder list was modified after the first iteration (note in the log Cass has her support recalculated and then it errors on the next iteration) to get that Linq error but just adding a .ToList() on the Citizens iterable prevents it erroring because of a change in the PawnsFinder list. This allowed the decision to cancel and the election to fire successfully on my save.

I haven't tested this solution fully (although I will play with it on my save going forward) so I'm not sure if it breaks anything else or if there's any other reason why this would be a dumb idea. If nothing else, however, this PR documents the bug a bit better than a Steam workshop comment, so I hope it's helpful :)

GarwelGarwel commented 1 year ago

Thanks, in fact this should already be fixed in the upcoming release.