SmArtKar / EnhancedBeliefs

Creative Commons Attribution 4.0 International
0 stars 1 forks source link

null reference on reform ideology #4

Open lilwhitemouse opened 4 months ago

lilwhitemouse commented 4 months ago

Exception filling window for RimWorld.Dialog_ReformIdeo: System.NullReferenceException: Object reference not set to an instance of an object [Ref C9725752] at EnhancedBeliefs.GameComponent_EnhancedBeliefs.BaseOpinionRecache (RimWorld.Ideo ideo) [0x00029] in :0 at EnhancedBeliefs.FluidIdeoTracker_Reformed.Postfix (RimWorld.IdeoDevelopmentTracker __instance) [0x0000b] in :0 at RimWorld.IdeoDevelopmentTracker.Notify_Reformed () [0x000e5] in <3d931901449c4087b86953a6d5c84d50>:0

  • POSTFIX rimworld.smartkar.enhancedbeliefs.main: Void EnhancedBeliefs.FluidIdeoTracker_Reformed:Postfix(IdeoDevelopmentTracker __instance) at RimWorld.IdeoDevelopmentUtility.ApplyChangesToIdeo (RimWorld.Ideo ideo, RimWorld.Ideo newIdeo) [0x0002f] in <3d931901449c4087b86953a6d5c84d50>:0 at RimWorld.Dialog_ReformIdeo.b__27_3 () [0x00000] in <3d931901449c4087b86953a6d5c84d50>:0 at RimWorld.IdeoDevelopmentUtility.ConfirmChangesToIdeo (RimWorld.Ideo ideo, RimWorld.Ideo newIdeo, System.Action confirmCallback) [0x00090] in <3d931901449c4087b86953a6d5c84d50>:0 at RimWorld.Dialog_ReformIdeo.DoWindowContents (UnityEngine.Rect inRect) [0x009e0] in <3d931901449c4087b86953a6d5c84d50>:0 at Verse.Window.InnerWindowOnGUI (System.Int32 x) [0x001a6] in <3d931901449c4087b86953a6d5c84d50>:0 UnityEngine.StackTraceUtility:ExtractStackTrace () Verse.Log:Error (string) Verse.Window:InnerWindowOnGUI (int) UnityEngine.GUI:CallWindowDelegate (UnityEngine.GUI/WindowFunction,int,int,UnityEngine.GUISkin,int,single,single,UnityEngine.GUIStyle)

Currently this means I can't reform the ideoligion because the exception stops processing the [DONE] button.

(Does the recaching also happen if the user makes changes with dev mode to an ideology?)

(If the ideo is the pawn's should it recalculate the opinions of all other ideologies?)

lilwhitemouse commented 4 months ago

How much unsolicited comments on code would you like, by the way?

SmArtKar commented 4 months ago

Oh feel free to comment on code as much as you want. Yeah this is an issue that I've been struggling to fix, its not happening 100% of the time either - I'm unsure of what's going on. BaseOpinionRecache() recaches opinion of all pawns on a specific ideo

lilwhitemouse commented 4 months ago

Is the opinion based on their own ideo?

lilwhitemouse commented 4 months ago

Well, I was going to put together a pull request, but you're building with C# version 12, and the highest I can use is C# 7. Things like return [baseIdeoOpinions[ideo] / 100f, PersonalIdeoOpinion(ideo) / 100f]; instead of the older return new float[2] {.....}

Trying to get that the make reasonable pull requests without changing large chunks of your code sounds complicated, unless you don't care about that

SmArtKar commented 4 months ago

I'm sorry but what is even preventing you from using C# 12 in the first place? Yes, opinions are partially based on their own ideo as well - memes like supremacist will lower opinion of all other ideos, plus pawns get opinion from similar memes.

lilwhitemouse commented 4 months ago

Monodevelop on Linux doesn't support C# 12 ¯\_(ツ)_/¯

You'll want to clear all of the pawn's opinions if the ideo needing to be re-cached is theirs - if their own idea changes to a supremecist, e.g.

SmArtKar commented 4 months ago

I downgraded the project to C# 7, its only a few minor changes.