RimWorld

RimWorld

Psychology (unofficial) v1.1-1.5
Atlas Aug 13, 2021 @ 1:14am
Infinite loop in BreakRelations
Assuming my version of this mod is up to date, there seems to be an infinite loop issue under certain circumstances in the
InteractionWorker_RomanceAttempt_BreakRelationsPatch::BreakRelations
method.

Inside the while loop, there's no exit case for when the pawn has a fiance and both pawns have the Polygamous trait. This causes the game to crash.
< >
Showing 1-3 of 3 comments
che_lovek  [developer] Aug 15, 2021 @ 11:03am 
If they are both Polygamous that function was not supposed to be called in the first place.
What were the exact circumstances of the error?
Atlas Aug 15, 2021 @ 3:12pm 
To repro this issue reliably, you can spawn a bunch of pawns with the psychology Polygamous trait, and pair some of them up as fiances. Once a successful romance check is made between a single pawn and one of the fiances, the game should crash (you can speed this up by modifying the RandomSelectionWeight and SuccessChance to always succeed).

I'm not 100% certain since I'm garbage at code, but I suspect it's because the BreakRelations method runs, the second half of the if/else statement is run, and the nested if statement checks whether one of the pawns is not Polygamous in order to break them up. But because both pawns are Polygamous, this is skipped and the loop starts again, running infinitely.

Sticking a message log in the while loop makes the game print it a bunch of times in the debug log before the game crashes.
The Word-Mule Sep 9, 2021 @ 12:56am 
Don't be hard on yourself, that debugging analysis suggests a much stronger familiarity with code than you suggest. :)
< >
Showing 1-3 of 3 comments
Per page: 1530 50