Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when right clicking certain objects in 1.3 #110

Open
jcstryker opened this issue Jul 22, 2021 · 1 comment
Open

Exception when right clicking certain objects in 1.3 #110

jcstryker opened this issue Jul 22, 2021 · 1 comment

Comments

@jcstryker
Copy link

Exception in RimWorld.FloatMenuMakerMap.ChoicesAtFor: System.InvalidOperationException: Sequence contains no matching element
  at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) [0x00011] in <351e49e2a5bf4fd6beabb458ce2255f3>:0 
  at RimWorld.RitualBehaviorWorker_Conversion.CanStartRitualNow (Verse.TargetInfo target, RimWorld.Precept_Ritual ritual, Verse.Pawn selectedPawn, System.Collections.Generic.Dictionary`2[TKey,TValue] forcedForRole) [0x0000b] in <8bc9a771920f4f8da0f2218f7c9cb0b0>:0 
  at Verse.Thing+<GetFloatMenuOptions>d__145.MoveNext () [0x0015e] in <8bc9a771920f4f8da0f2218f7c9cb0b0>:0 
  at Verse.ThingWithComps+<GetFloatMenuOptions>d__40.MoveNext () [0x00078] in <8bc9a771920f4f8da0f2218f7c9cb0b0>:0 
  at RimWorld.FloatMenuMakerMap.AddHumanlikeOrders (UnityEngine.Vector3 clickPos, Verse.Pawn pawn, System.Collections.Generic.List`1[T] opts) [0x0462d] in <8bc9a771920f4f8da0f2218f7c9cb0b0>:0 
     - transpiler LWM.DeepStorage: IEnumerable`1 LWM.DeepStorage.Patch_AddHumanlikeOrders:Transpiler(IEnumerable`1 instructions)
     - prefix LWM.DeepStorage: Boolean LWM.DeepStorage.Patch_AddHumanlikeOrders:Prefix(Vector3 clickPos, Pawn pawn, List`1 opts)
     - postfix OskarPotocki.HeavyWeapons: Void HeavyWeapons.Patch_FloatMenuMakerMap+AddHumanlikeOrders_Fix:Postfix(Vector3 clickPos, Pawn pawn, List`1& opts)
     - postfix OskarPotocki.VFECore: Void VFECore.Patch_FloatMenuMakerMap+AddHumanlikeOrders_Fix:Postfix(Vector3 clickPos, Pawn pawn, List`1& opts)
     - postfix LWM.DeepStorage: Void LWM.DeepStorage.Patch_AddHumanlikeOrders:Postfix(List`1 opts)
  at RimWorld.FloatMenuMakerMap.ChoicesAtFor (UnityEngine.Vector3 clickPos, Verse.Pawn pawn, System.Boolean suppressAutoTakeableGoto) [0x000db] in <8bc9a771920f4f8da0f2218f7c9cb0b0>:0 
     - postfix net.pardeike.rimworld.mods.achtung: Void AchtungMod.FloatMenuMakerMap_ChoicesAtFor_Postfix:Postfix(List`1 __result, Vector3 clickPos, Pawn pawn)
     - finalizer net.pardeike.rimworld.mods.achtung: Exception AchtungMod.FloatMenuMakerMap_ChoicesAtFor_Finalizer:Finalizer(Exception __exception, List`1& __result)
@jtgibson01
Copy link

jtgibson01 commented Sep 25, 2021

Having looked into this, I can definitively confirm the cause. This is a vanilla bug exposed by modding; the culprit is:

Precept_Role precept_Role = ritual.ideo.RolesListForReading.First((Precept_Role r) => r.def == PreceptDefOf.IdeoRole_Moralist);

in RimWorld.RitualBehaviorWorker_Conversion.CanStartRitualNow().

The IEnumerable<>.First() function automatically throws an exception if it doesn't find an element, whereas Tynan (or whoever else is programming at Ludeon, if he has a team now) should be using FirstOrDefault, and should be verifying against null in the next line too.

The cause is when you have an ideology assigned to your colony that doesn't have a spiritual leader role defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants