Can someone tell me what this error means?

Started by Scorpinax, September 10, 2019, 09:18:13 PM

Previous topic - Next topic

Scorpinax

I'm working on my mask mod, and im very close to finishing and releasing the mod. But i keep running into this error whenever i spawn a mask in, and the error happens seemingly at random. It isn't consistent seemingly at all. IE: when i spawn a mask in it throws this error on occasion, but spawning the mask doesn't always throw the error.

All i'm running is Core, and the Mod im working on.

Root level exception in OnGUI(): System.ArgumentException: An element with the same key already exists in the dictionary.
  at System.Collections.Generic.Dictionary`2[RimWorld.GenLabel+LabelRequest,System.String].Add (LabelRequest key, System.String value) [0x00000] in <filename unknown>:0
  at RimWorld.GenLabel.ThingLabel (Verse.Thing t, Int32 stackCount, Boolean includeHp) [0x00000] in <filename unknown>:0
  at Verse.Thing.get_LabelNoCount () [0x00000] in <filename unknown>:0
  at Verse.ThingWithComps.get_LabelNoCount () [0x00000] in <filename unknown>:0
  at Verse.Thing.get_Label () [0x00000] in <filename unknown>:0
  at Verse.Thing.get_LabelCap () [0x00000] in <filename unknown>:0
  at Verse.Entity.get_LabelMouseover () [0x00000] in <filename unknown>:0
  at Verse.MouseoverReadout.MouseoverReadoutOnGUI () [0x00000] in <filename unknown>:0
  at RimWorld.MapInterface.MapInterfaceOnGUI_AfterMainTabs () [0x00000] in <filename unknown>:0
  at RimWorld.UIRoot_Play.UIRootOnGUI () [0x00000] in <filename unknown>:0
  at Verse.Root.OnGUI () [0x00000] in <filename unknown>:0
Verse.Log:Error(String, Boolean)
Verse.Root:OnGUI()


Any help would be greatly appreciated. The error doesnt seem to cause any serious issues but i would like to have it completely bug free b4 release.

Scorpinax

all of the masks use basically the same code and they all use the same parent.

mask code;

  <ThingDef ParentName="ScorpRareBase">
    <defName>Apparel_MaskEyeball</defName>
    <label>Mask: Eyeball</label>
    <description>Description</description>
   
    <graphicData>
      <texPath>Things/Apparel/MaskEyeball/MaskEyeball</texPath>
      <graphicClass>Graphic_Single</graphicClass>
    </graphicData>
    <statBases>
      <MarketValue>260</MarketValue>
      <MaxHitPoints>150</MaxHitPoints>
      <Mass>0.15</Mass>
      <EquipDelay>1.0</EquipDelay>
    </statBases>
    <equippedStatOffsets>
      <MentalBreakThreshold>-0.01</MentalBreakThreshold>
      <PsychicSensitivity>-0.10</PsychicSensitivity>
      <MoveSpeed>0.02</MoveSpeed>
    </equippedStatOffsets>
   <generateCommonality>0.05</generateCommonality>
    <apparel>
      <bodyPartGroups>
        <li>FullHead</li>
      </bodyPartGroups>
      <wornGraphicPath>Things/Apparel/MaskEyeball/MaskEyeball</wornGraphicPath>
      <layers>
        <li>Overhead</li>
      </layers>
      <tags>
        <li>Raider</li>
        <li>IndustrialBasic</li>
        <li>IndustrialAdvanced</li>
      </tags>
      <defaultOutfitTags>
        <li>Worker</li>
        <li>Soldier</li>
      </defaultOutfitTags>
    </apparel>
    <colorGenerator Class="ColorGenerator_Options">
      <options>
        <li>
          <weight>4</weight>
          <only>RGBA(1,1,1,1)</only>
        </li>
      </options>
    </colorGenerator>
  </ThingDef>
 


LWM


Scorpinax

Quote from: LWM on September 15, 2019, 03:23:30 PM
Do your masks (in the defs) useHitPoints?

The parent base has "useHitpoints" to false, so they dont degrade, but they have hitpoints defined in the masks themselves... Do you think that's whats causing the issue?

LWM

#4
YES.

Edit: an explanation:

The label database (to cache labels to save time) uses a hash for each object.  An object's hash is created from all the usual stuff, including the number of hitpoints - IF useHitPoints is true.

However, two object labels will be different if they have different hitpoints, because the "Equals()" test between object labels tests hitpoints, regardless.

So the label database looks for the label, finds a matching hash, but it's not a matching key because hitpoints are different.  So it adds the new one to the database....but because useHitPoints is false, the hash is identical to another one already there.  So it throws the appropriate exception.

Find some other way to keep it from decaying (minified objects do it?) or give it up.  Or, you know, test it first and see if I'm correct  ;D ;D ;D

No promises ;)

--LWM

Scorpinax

Holy crap you're right! All I had to do was remove the max hit points from the masks themselves, and no more errors being thrown. Seems I don't have to even find a workaround for the 'never degrade' part since it still works as intended.

Thank you so much   ;D