Mehni / kNumbers

Quick comparison of colonist stats
MIT License
34 stars 28 forks source link

Bug: A tab breaks entirely when something "unexpected" is added for display #67

Open xCharg opened 1 year ago

xCharg commented 1 year ago

I've been messing around with what stats to display on wild animals tab (I'd assume same bug could happen on other tabs as well). I've added some column (don't remember which one specifically), and it "broke" entire wild animals tab. Player.log has this error when I try to open this tab:

    Exception filling window for Numbers.MainTabWindow_Numbers: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
      at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00029] in <eae584ce26bc40229c1b1aa476bfa589>:0 
      at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in <eae584ce26bc40229c1b1aa476bfa589>:0 
      at (wrapper dynamic-method) RimWorld.PawnTable.RimWorld.PawnTable.PawnTableOnGUI_Patch0(RimWorld.PawnTable,UnityEngine.Vector2)
      at RimWorld.MainTabWindow_PawnTable.DoWindowContents (UnityEngine.Rect rect) [0x00020] in <95de19971c5d40878d8742747904cdcd>:0 
      at Numbers.MainTabWindow_Numbers.DoWindowContents (UnityEngine.Rect rect) [0x003be] in <9ff61b29a7ab468ba28486fbf1f24cff>:0 
      at Verse.Window.InnerWindowOnGUI (System.Int32 x) [0x001d3] in <95de19971c5d40878d8742747904cdcd>:0  
    (Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

I've compared my save file to oldest autosave and this element was the difference:

    <li Class="Numbers.WorldComponent_Numbers">
        <Numbers_Numbers_WildAnimals>
            <li>Numbers_RimWorld_AbilityDef_AnimalCalm</li>
        </Numbers_Numbers_WildAnimals>
    </li>
xCharg commented 1 year ago

Actually disregard the difference part - removing this list element from save file didn't fix it. So I've removed entire <li Class="Numbers.WorldComponent_Numbers"> block and now issue is fixed.

Would be nice to prevent it from happening in the first place though.

This is what's been there, maybe you'll be able to spot what went wrong - I didn't.

    <li Class="Numbers.WorldComponent_Numbers">
        <Numbers_Numbers_MainTable>
            <li>LabelShortWithIcon</li>
            <li>Numbers_Equipment</li>
            <li>MedicalCare</li>
            <li>Numbers_DiseaseProgress</li>
            <li>Numbers_Inspiration</li>
            <li>Numbers_RimWorld_StatDef_AimingDelayFactor</li>
            <li>Numbers_RimWorld_RecordDef_Kills</li>
            <li>Numbers_RimWorld_StatDef_ShootingAccuracyPawn</li>
            <li>Numbers_RimWorld_StatDef_TameAnimalChance</li>
            <li>Numbers_RimWorld_StatDef_NegotiationAbility</li>
            <li>Numbers_RimWorld_StatDef_WorkSpeedGlobal</li>
            <li>Numbers_RimWorld_NeedDef_Mood</li>
            <li>RemainingSpace</li>
        </Numbers_Numbers_MainTable>
        <Numbers_Numbers_Enemies>
            <li>LabelShortWithIcon</li>
            <li>Numbers_Equipment</li>
            <li>Numbers_Pain</li>
            <li>Numbers_RimWorld_StatDef_AimingDelayFactor</li>
            <li>Numbers_RimWorld_StatDef_MeleeDPS</li>
            <li>Numbers_RimWorld_StatDef_ShootingAccuracyPawn</li>
            <li>Numbers_RimWorld_StatDef_MoveSpeed</li>
            <li>Numbers_TraitsColored</li>
            <li>RemainingSpace</li>
        </Numbers_Numbers_Enemies>
        <Numbers_Numbers_WildAnimals>
            <li>LabelWithIcon</li>
            <li>Gender</li>
            <li>LifeStage</li>
            <li>GapTiny</li>
            <li>GapTiny</li>
            <li>Hunt</li>
            <li>GapTiny</li>
            <li>Tame</li>
            <li>ManhunterOnDamageChance</li>
            <li>ManhunterOnTameFailChance</li>
            <li>Predator</li>
            <li>Numbers_Wildness</li>
            <li>Numbers_TameChance</li>
            <li>Info</li>
            <li>Numbers_RimWorld_StatDef_MeatAmount</li>
            <li>Numbers_RimWorld_StatDef_LeatherAmount</li>
            <li>Numbers_RimWorld_RecordDef_Kills</li>
            <li>Numbers_RimWorld_AbilityDef_AnimalCalm</li>
            <li>RemainingSpace</li>
        </Numbers_Numbers_WildAnimals>
        <Numbers_Numbers_AnimalCorpses>
            <li>LabelWithIcon</li>
            <li>Numbers_Forbidden</li>
            <li>Numbers_LeatherType</li>
            <li>Numbers_RimWorld_StatDef_FoodPoisonChanceFixedHuman</li>
            <li>Numbers_RimWorld_StatDef_MeatAmount</li>
            <li>Numbers_RimWorld_StatDef_LeatherAmount</li>
            <li>RemainingSpace</li>
        </Numbers_Numbers_AnimalCorpses>
    </li>
xCharg commented 1 year ago

Steps to reproduce:

  1. open wild animals tab
  2. click on Abilities > choose any
  3. this tab is broken now until: a) entire <li Class="Numbers.WorldComponent_Numbers"> element is removed from save file AND b) game is restarted

Just removing element without restarting the game doesn't help. If you're not saving after reproducing bug then just restarting a game is enough. Adding player.log just in case Player-prev.log