Vectorial1024/Desynchronized

Argument out of range when selecting news to transmit: boundary case

Closed this issue · 1 comments

Occurs when there are no news to transmit, but the TNDBS requests for one to be transmitted. This can happen when a new game is recently started with this mod active.

Dev note: TaleNewsColonyEstablished is not implemented currently (v1.5.0).

Example log follows:

Exception ticking Fiddler (at (92, 0, 172)): System.ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
at System.Collections.Generic.List`1<Desynchronized.TNDBS.TaleNewsReference>.get_Item (int) <0x00083>
at Desynchronized.TNDBS.NewsSpreadUtility.SelectNewsRandomly (Verse.Pawn,Verse.Pawn,Desynchronized.TNDBS.TaleNewsReference&) <0x00365>
at Desynchronized.TNDBS.NewsSpreadUtility.DetermineTaleNewsToTransmit (Verse.Pawn,Verse.Pawn,Desynchronized.TNDBS.NewsSpreadUtility/SpreadMode) <0x0006b>
at Desynchronized.TNDBS.NewsSpreadUtility.SpreadNews (Verse.Pawn,Verse.Pawn,Desynchronized.TNDBS.NewsSpreadUtility/SpreadMode) <0x00025>
at Desynchronized.Patches.PostFix_InteractionWorker.PostFix (RimWorld.InteractionWorker,Verse.Pawn,Verse.Pawn) <0x000cc>
at (wrapper dynamic-method) RimWorld.InteractionWorker.Interacted_Patch1 (object,Verse.Pawn,Verse.Pawn,System.Collections.Generic.List`1<Verse.RulePackDef>,string&,string&,Verse.LetterDef&) <0x00051>
at (wrapper dynamic-method) RimWorld.Pawn_InteractionsTracker.TryInteractWith_Patch1 (object,Verse.Pawn,RimWorld.InteractionDef) <0x005b2>
at Hospitality.Harmony.Pawn_InteractionsTracker_Patch/TryInteractRandomly.Replacement (RimWorld.Pawn_InteractionsTracker,bool&) <0x00433>
at (wrapper dynamic-method) RimWorld.Pawn_InteractionsTracker.TryInteractRandomly_Patch1 (object) <0x0003d>
at RimWorld.Pawn_InteractionsTracker.InteractionsTrackerTick () <0x0016a>
at (wrapper dynamic-method) Verse.Pawn.Tick_Patch1 (object) <0x003d7>
at (wrapper dynamic-method) Verse.TickList.Tick_Patch2 (object) <0x00497>

Wrong assumption, and, thus, conclusion, was made. Bug is unrelated to the existence of TaleNews. A wrong variable was used in place of the correct one in the random-weighted algorithm to select the TaleNews to transmit.

The shape and working principle of the algorithm has already been confirmed to be correct before the algorithm is implemented here, just that one of the variables appeared in the wrong position. Hence, the game always selects a TaleNews with an invalid index, causing the error.

The fix is inside the upcoming v1.5.1.