Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.

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

Open
stasikos opened this issue Oct 31, 2016 · 1 comment

Comments

@stasikos
Copy link

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.

@Crzyrndm
Copy link
Owner

Crzyrndm commented Oct 31, 2016

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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants