Jump to content
The simFlight Network Forums

Timothee1

Members
  • Posts

    5
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Switzerland

Timothee1's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi Paul Thanks, that would explain why it happens rather rarely. In the meantime I will use double.IsNaN() to prevent a problem on my side. I will also add some logging and will hopefully find some coordinates which could lead to this result. Regards
  2. Hi As stated in the title I have some rare conditions where DistanceFromInNauticalMiles() returns NaN instead of a number. I try to track the flown distance. To accomplish this, I get the current coordinates and one minute later the new coordinates, calculate the distance between both points and sum up the total distance everytime. I simplified my code a little bit to show you what I have. The method CalcPlayerDistance() is the original method I'm using in my program. The main() method is just used to demonstrate how the logic works. internal class Program { private FsLatitude previousPlayerLatitude; private FsLongitude previousPlayerLongitude; internal FsLatitude PlayerLatitude { get; private set; } internal FsLongitude PlayerLongitude { get; private set; } internal double TrackedPlayerDistance{ get; private set; } private Offset<long> playerLatitudeOffset = new Offset<long>(0x0560); private Offset<long> playerLongitudeOffset = new Offset<long>(0x0568); private double CalcPlayerDistance() { double playerDistance; PlayerLongitude = new FsLongitude(playerLongitudeOffset.Value); PlayerLatitude = new FsLatitude(playerLatitudeOffset.Value); // Initialize previous coordinates on start if (previousPlayerLatitude.DecimalDegrees == 0 && previousPlayerLongitude.DecimalDegrees == 0 && TrackedPlayerDistance == 0) { previousPlayerLatitude = PlayerLatitude; previousPlayerLongitude = PlayerLongitude; } FsLatLonPoint currentPosition = new FsLatLonPoint(PlayerLatitude, PlayerLongitude); playerDistance = currentPosition.DistanceFromInNauticalMiles(new FsLatLonPoint(previousPlayerLatitude, previousPlayerLongitude)); previousPlayerLatitude = PlayerLatitude; previousPlayerLongitude = PlayerLongitude; return playerDistance; } [STAThread] public static void Main() { Program distanceTest = new Program(); while(true) { distanceTest.TrackedPlayerDistance += distanceTest.CalcPlayerDistance(); Thread.Sleep(60000); } } } At the end I rarely end up with TrackedPlayerDistance being NaN. Unfortunately I can't reproduce it and I dont know when it happens yet since once TrackedPlayerDistance is NaN it will stay NaN. Im using the same method to calculate the remaining distance to the destination airport: DistanceToDestNm = (int)Math.Round(new FsLatLonPoint(PlayerLatitude, PlayerLongitude).DistanceFromInNauticalMiles(arrivalAirport)); This would not directly end up in NaN since im casting to int but instead would end up in something like -2147483648. Unlike the first case it never happened here. Does anyone have an idea what im doing wrong in the first case and how to prevent it? If there is a better way to accomplish what I'm looking for I'm happy for hints. Regards
  3. Thank you for the replies. I'm aware that XPUIPC is from another developer. However I was just asking for ideas in general. It looks like I havent properly studied the XPUIPC documention. XPUIPC offers additonal offsets which may help me to solve this problem, for example: 6F03 - XPUIPC Version string with 0 terminator Regards Timothee
  4. Hi Is there any way to reliably differentiate between FSUIPC and XPUIPC? Some functions need special handling, depending which simulator is being used. Using FsVersion results in FSX if used with XPUIPC. Do you have any suggestions? Regards Timothee
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.