linuxgurugamer / EvaFuel

A mod for Kerbal Space Program that makes Kerbals no longer be able to have infinite EVA fuel. A continuation of Vendan's mod of the same name.
http://forum.kerbalspaceprogram.com/index.php?/topic/138474-111-105-evafuel-no-more-infinite-eva-fuel/
MIT License
3 stars 5 forks source link

I get more EVA fuel than I have in my ship #16

Open Genhis opened 4 years ago

Genhis commented 4 years ago
  1. A ship has 2 units of Monopropellant
  2. A kerbal gets out with 5 units (where the 3 units come from nobody knows)
  3. The kerbal gets back inside
  4. The ship has now 5 units, what a miracle! :D

So, an incorrect amount is taken but a correct amount is returned back.

This issue does not seem to be mod-specific, rather a save-specific one. I have 2 save games which work normally and 2 others which don't. I can't seem to figure out what is causing the issue but every time it doesn't work, an error appears in the log 4 times.

[LOG 19:41:35.133] [PartSet]: Failed to add Resource -1511737247 to Simulation PartSet:76 as corresponding Part -3400877523 SimulationResource was not found.

Number -1511737247 is the same but the second negative number changes. Note that I get a message stating that I am low on fuel which has the correct amount (2 units) but my kerbal still gets 5 units.

I have tested it with different mod configurations, adding and removing mods, but nothing has helped.

My mod list:

Please let me know if you want the save games or more log files.

Genhis commented 4 years ago

Well, it turns out that male pilots get correct amount but females don't.

Variable data.to.Resources is empty for females when onEvaStart() is called - females don't have any resources associated with them? Yet I can see the propellant in the resource GUI...

Male part type: kerbalEVA Female part type: kerbalEVAfemaleVintage

linuxgurugamer commented 4 years ago

That makes sense, I'll see if I can get this fixed in the next day or so

Genhis commented 4 years ago

Thanks for the quick response.

In the meantime, I have investigated the problem further and managed to find a workaround. In GameData\Squad\Parts\Prebuilt, copy kerbalEVAfemale.cfg to kerbalEVAfemaleVintage.cfg and change the part name in the copied file. I don't know why it works this way and it's likely that future KSP versions may break this workaround, so a proper fix would be welcome. I don't have any DLC installed if that matters.

Hopefully this information will help you fix the bug.

linuxgurugamer commented 4 years ago

First, can you send me a log file? Second, I'm very puzzled, looking at a 1.10.1 install, in KSP_1.10.1_dev\GameData\Squad\Parts\Prebuilt there are only two files, kerbalEVA.cfg and kerbalEVAfemale.cfg. So, are you copying kerbalEVAfemale.cfg to a new file called kerbalEVAfemaleVintage.cfg?

and while it makes sense (because they are different internally), I don't see anything in the code which would cause this.

Genhis commented 4 years ago

Yes, I copied the female file to the new one and edited the part name to kerbalEVAfemaleVintage. As far as I know, kerbalEVAfemaleVintage.cfg is included in Making History DLC, but why is it necessary for the stock game...

Here are the log files. I removed the other mods for the testing purposes. before-fix.txt before-fix-modified.txt after-fix-modified.txt

I modified the code to enable logging and to add more debugging statements.

onEvaStart():

else
{
    Log.Info("resource: " + resourceName);
    foreach(PartResource r in data.to.Resources)
        Log.Info(r.ToString());

    Log.Info(data.to.RequestResource(resourceName, evaTankFuelMax - (fuelRequest + fuelInEVAPack)).ToString());
    Log.Info("after");
    if (ShowLowFuelWarning && (!DisableLowFuelWarningLandSplash || !data.from.vessel.LandedOrSplashed))
    {
        PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "evafuel2", "Low EVA Fuel!", "Warning! Only " + Math.Round(takenFuel, 2).ToString() + " units of " + HighLogic.CurrentGame.Parameters.CustomParams<EVAFuelSettings>().ShipPropellantName + " were available for EVA! Meaning you only have " + Math.Round(fuelRequest, 2).ToString() + " units of " + resourceName + "!", "OK", false, HighLogic.UISkin);
    }
}

onEvaHandler():

var kerbalResourceList = data.to.Resources;//.Where(p => p.resourceName == shipPropName);

It may be a KSP bug, but why does it work fine when a female kerbal enters a ship (there is no "Failed to add Resource" error message)?