voult2 / BetterPawnControl

A RimWorld mod that allows bulk assignment of animals to zones and colonists to outfits (or drugs) in one single action
MIT License
20 stars 21 forks source link

feat: be 'autocleaner' compatible by allowing pawns without timetables #25

Closed muggenhor closed 3 years ago

muggenhor commented 3 years ago

This treats the pawns' timetables as optional, allowing them to be null. As a result autocleaners, which don't have a timetable, no longer cause a null pointer exception when trying to close the schedule tab.

I've tested this and confirmed it to work with RimWorld 1.2.2753 and Autocleaner 1.2 (AUTOMATIC1111/Autocleaner@c115e0b6dd279e3adefbe8c9332fb09c4d4c7d1b).

The exception that gets thrown without this change when (a) you have the autocleaner mod and an activated autocleaner and (b) try to close the schedule tab:

Root level exception in OnGUI(): System.NullReferenceException: Object reference not set to an instance of an object
  at BetterPawnControl.RestrictManager.SaveCurrentState (System.Collections.Generic.List`1[T] pawns) [0x000bf] in <58c5b65fc83547e7afaa09327dc70563>:0 
  at BetterPawnControl.MainTabWindow_Restrict_Policies.PreClose () [0x00026] in <58c5b65fc83547e7afaa09327dc70563>:0 
  at Verse.WindowStack.TryRemove (Verse.Window window, System.Boolean doCloseSound) [0x00047] in <d72310b4d8f64d25aee502792b58549f>:0 
  at RimWorld.MainTabsRoot.ToggleTab (RimWorld.MainButtonDef newTab, System.Boolean playSound) [0x00056] in <d72310b4d8f64d25aee502792b58549f>:0 
  at RimWorld.MainButtonWorker_ToggleTab.Activate () [0x00005] in <d72310b4d8f64d25aee502792b58549f>:0 
  at RimWorld.MainButtonWorker.InterfaceTryActivate () [0x0004d] in <d72310b4d8f64d25aee502792b58549f>:0 
  at (wrapper dynamic-method) RimWorld.MainButtonWorker.RimWorld.MainButtonWorker.DoButton_Patch0(RimWorld.MainButtonWorker,UnityEngine.Rect)
  at RimWorld.MainButtonsRoot.DoButtons () [0x0010c] in <d72310b4d8f64d25aee502792b58549f>:0 
  at RimWorld.MainButtonsRoot.MainButtonsOnGUI () [0x0000e] in <d72310b4d8f64d25aee502792b58549f>:0 
  at RimWorld.UIRoot_Play.UIRootOnGUI () [0x00037] in <d72310b4d8f64d25aee502792b58549f>:0 
  at (wrapper dynamic-method) Verse.Root.Verse.Root.OnGUI_Patch1(Verse.Root)
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 35)