RemoteTechnologiesGroup / RemoteTech

Community developed continuation of Kerbal Space Program's RemoteTech mod.
http://remotetechnologiesgroup.github.io/RemoteTech
GNU General Public License v2.0
230 stars 103 forks source link

API - Return float for Distance/MaxDistance #766

Closed HaullyGames closed 5 years ago

HaullyGames commented 5 years ago

Could you please Add a new API method to return a float(% of max range)? Need it to define bandwidth in Kerbalism.

Thanks

HaullyGames commented 5 years ago

for example: float GetSignalStrength(Guid A, Guid B)

KSP-TaxiService commented 5 years ago

Hi,

Are you okay with this methods of double-type return? You don't need to get from RT the current range distance between A and B as you can calculate straight from A and B positions.

public static double GetMaxRangeDistance(Guid A, Guid B)

HaullyGames commented 5 years ago

That will be perfect. Thanks

KSP-TaxiService commented 5 years ago

Hi, please verify this new method at your end.

KSP-TaxiService commented 5 years ago

@HaullyGames A gentle reminder before I publish a new official RT release

HaullyGames commented 5 years ago

Sorry, I didn't test the distance yet, I should test it tonight.

HaullyGames commented 5 years ago

The module works!

But I would like to do a new requirement or help from you. When the vessel has direct connection with the GroundStation, how can I get the distance between a vessel and RT_groundStation? I can get the distance between two vessels then divide by max_distance and get the perct, but I can't find the distance between a vessel and RT groundstation.

UPDATE I found something

Could you please add the RangeModelExtensions.DistanceTo() to API? but it needs to receive GUID then find the ISatellite, like all other API modules.

Also, with this new change, could you please update the API.GetControlPath to include the groundstation guid?

// Get all satellites, not the last jump that is a station ground
            for (int i = 0; i < bestRouter.Count - 1; i++)

To


// Get all satellites till the station ground
            for (int i = 0; i < bestRouter.Count; i++)
KSP-TaxiService commented 5 years ago

You may test both GetMaxRangeDistance and GetRangeDistance between ground station and vessels. They should work fine.

HaullyGames commented 5 years ago

Thanks, I will test it tonight, in few hours I can confirm to you.

HaullyGames commented 5 years ago

Hi @KSP-TaxiService , not sure because I didn't test yet, but I think the "for" will break the array index.

I think you need to remove the -1 from Guid[] guids = new Guid[bestRouter.Count - 1]; as you did for the "for", otherwise you will have an array of x-1 indexes, and will try add x indexes into it.

HaullyGames commented 5 years ago

Yep, error about index is out of range

IndexOutOfRangeException: Array index is out of range.
    RemoteTech.API.API.GetControlPath (Guid id)
KSP-TaxiService commented 5 years ago

Oops my bad. Please try again.

HaullyGames commented 5 years ago

All good, please let me know when you release. Everything working fine, Kerbalism will wait for your release now.

KSP-TaxiService commented 5 years ago

Thanks, it will be out in one or two days. It is undergone the rigorous testing on the KSP major version

Gordon-Dry commented 5 years ago

When you release, please backport to KSP 1.4.5 because many players cannot move to 1.5.x - at least because of Kopernicus which waits for a proper release of KSP 1.5.2+