My mod has a FormList, and it adds some entries to it if Dawnguard is present. Now, I was trying to be clever, and handle the case where the user enables Dawnguard, plays for a while, disables Dawnguard, plays for a while, enables Dawnguard again. So, I have an OnPlayerLoadGame() event in my script, where I look to see whether Dawnguard has been loaded or not, via Game.GetFormFromFile(...). If Dawnguard is loaded, then I look to see whether my FormList has the new entries in it, or not, via FormList.HasForm(). So, the code looks something like this, minus error handling, comments, and a loop:
Form dawnguardProbe = Game.GetFormFromFile(0x000034dc, "Dawnguard.esm") bool dawnguardLoaded = (dawnguardProbe != None) if dawnguardLoaded ; Does booklist include Dawnguard books? if !UBGAllBooksGlowList.HasForm(dawnguardProbe) UBGAllBooksGlowList.AddForm(dawnguardProbe)
Now, I was assuming that if the user disabled Dawnguard and continued playing, the Dawnguard forms that I added to the FormList would just be cleared out of the FormList. That was apparently wrong. The entries seem stay in the list, but in some "zombie" fashion I haven't totally figured out. If the user re-enables Dawnguard, and the code above runs for the second time, HasForm(X) returns _false_ instead of _true_, even though GetSize() shows that the "old" X added by the first run of this code has not been removed from the list. So, basically, every time this sequence of events happens (which admittedly should be rare), the formlist will grow in size and gain some more "zombie" entries. Which is no doubt bad.
So, has anyone seen behavior like this, or have any comments? I'm now investigating FormList.Revert() as a workaround. Hopefully that isn't buggy as well.