B9-PWings-Fork icon indicating copy to clipboard operation
B9-PWings-Fork copied to clipboard

adding KSPI radiators (or, just resources) can break FuelVolumeChanged() method for wing.

Open stasikos opened this issue 8 years ago • 1 comments

Tried to use KSPI and this mod and "Mk2 extended KSPI integration" together and it seems it works incorrectly - "J" key does nothing. After some time spent in debugging I noticed Mk2 KSPI Integration adds radiators to wings (via MM patch). Simpliest way to fix is to change patch, of course, but I did more digging.

After little code changes to debug... for (int i = 0; i < part.Resources.Count; ++i) { PartResource res = part.Resources[i]; Debug.Log ("PartResource = " + res.resourceName); double fillPct = res.maxAmount > 0 ? res.amount / res.maxAmount : 1.0; WingTankConfiguration tankSetup = StaticWingGlobals.wingTankConfigurations [fuelSelectedTankSetup]; Debug.Log ("Got tankSetup = " + tankSetup.GUIName); WingTankResource resource = tankSetup.resources [res.resourceName]; Debug.Log ("Got Resource units/vol = " + resource.unitsPerVolume); res.maxAmount = aeroStatVolume * resource.unitsPerVolume; res.amount = res.maxAmount * fillPct; }

I got this:

[LOG 09:41:58.386] PartResource = WasteHeat [LOG 09:41:58.386] Got tankSetup = STR [EXC 09:41:58.386] KeyNotFoundException: The given key was not present in the dictionary. System.Collections.Generic.Dictionary`2[System.String,WingProcedural.WingTankResource].get_Item (System.String key) WingProcedural.WingProcedural.FuelVolumeChanged () WingProcedural.WingProcedural.UpdateGeometry (Boolean updateAerodynamics) WingProcedural.WingProcedural.RefreshGeometry () WingProcedural.WingProcedural.Setup () WingProcedural.WingProcedural.Start ()

Obviously WasteHeat can't be in STR TankSetup, so it throws exception. For sure, I reported this issue to (very old) Mk2 KSPI Integration thread, but, just in case, there can be a workaround against such case in B9 PWings too.

stasikos avatar Oct 31 '16 08:10 stasikos

Latest commit should fix this issue (in the sense that it won't explode, it'll still nuke the resource for now if the configuration changes)

Crzyrndm avatar Oct 31 '16 08:10 Crzyrndm