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

Improve rescue contract logic #2

Closed linuxgurugamer closed 6 years ago

linuxgurugamer commented 7 years ago

Mk1 Crew Cabins have full resources, apparently, so they don't get caught by the rescue fuel logic.

All other parts so far seem to be empty as they normally are.

Need to figure out (by parsing contracts? Ugh.) a better way to detect rescue ships.

Somewhat addressed by 245703c, where it gets the Kerbal name and checks if they've got a contract with their name and are exiting from a vessel with their name.

It works better now, but I'm leaving this open since keeping a Kerbal in space instead of finishing the contract means you can name the vessel after them and get more free fuel if you don't have any EVA fuel in the ship in question. Granted, this isn't likely to ever be accidentally done, but I'd like to eventually find a proper fix.

canisin commented 6 years ago

Copied from the forum: https://forum.kerbalspaceprogram.com/index.php?/topic/158156-131-evafuel-continued-no-more-infinite-eva-fuel/&do=findComment&comment=3104240

I went digging into the code, and found the part that handles rescue ships. The conditions for detecting a rescue ship are as follows:

contracts[currentContract].Title.Contains(crewList[currentCrew].name) && data.from.vessel.name.Contains(crewList[currentCrew].name.Split(null)[0])

This means that for a ship to be considered a rescue ship, it must contain a kerbal whose name appears in a contract's name, and for the ship's name to contain that kerbal's name. But the two conditions handle names differently. The first condition requires the kerbal's name to appear fully in the contract title, whereas the second condition requires only the first word of the name to appear in the ship's name.

Right now, I am trying to rescue "Maegan Kerman". The name of the contract is "Rescue Maegan from orbit of Kerbin.", the name of the ship is "Maegan's Pod". So my guess is that the mod expects the contract to contain the kerbal's surname, but it seems that something has changed with the naming of rescue contracts.