Jump to content
The simFlight Network Forums

FSUIPCConnection.MoveAircraft() Overload Request


Recommended Posts

Hey Paul,

Was working today with your FSUIPCConnection.MoveAircraft() function and was noticing that it is really missing one overload for it.  I'm using the full form of:

public static void MoveAircraft(FsLatLonPoint NewLocation, bool OnGround, FsAltitude? Alt, double? HeadingTrue, double? Pitch, double? Bank, double? IndicatedAirSpeedKnots, bool LeavePaused);

And one thing that would be really nice is the ability to specify the time/season in there as well.  Any chance that could be a part of the function?  Right now, it takes two separate loads to first put the plane into position and then a second load to then change the time.  It would be real handy, if possible, to move the plane and set the time/season in one call and eliminate the double scenery loading times.


Link to comment
Share on other sites

BTW - the P3D flags for time/season are:

        private Offset<short> season = new Offset<short>(0x0248); //Season: 0=Winter, 1=Spring, 2=Summer, 3=Fall
        private Offset<byte> hour = new Offset<byte>(0x0238); //local hour of the flight sim
        private Offset<int> sendControl = new Offset<int>(0x3110, true); // Offset for moving the plane
        private readonly int REFRESH_SCENERY = 65562; // Control number to refresh the scenery     

The calling code is:

            //set the time/season
            this.hour.Value = Convert.ToByte(iHour);
            this.season.Value = 0;
            sendControl.Value = REFRESH_SCENERY;

Link to comment
Share on other sites

Hi Dirk,

Are you sure that writing to 0248 changes the season in p3D? It doesn't in FSX and is marked as read-only in the FSUIPC Offsets List.

The MoveAircraft() method uses offset 0558, which uses a special feature of SimConnect to move the aircraft. This feature doesn't include the season or date time so there's no way I can include it.

I have experimented with this in FSX (I don't have p3d) and found that writing a new datetime and then calling MoveAircraft() only does one scenery refresh. Normally either of these would reload the scenery. But calling them one after the other doesn't do two loads. It seems to abort the first load when starting the second.

Here is the code I used: (I used the snapshot overload but it uses the same code. I had to change the season by setting a new date as 0248 is read-only (at least in FSX):

            FSUIPCConnection.UTCDateTime = dateTimeSave;
            FSUIPCConnection.MoveAircraft(posSave, false);

So I think you can achieve what you want by using this method.

Alternatively if you want to use this code (assuming it works in P3D):

            //set the time/season
            this.hour.Value = Convert.ToByte(iHour);
            this.season.Value = 0;
            sendControl.Value = REFRESH_SCENERY;

... you can try not refreshing the scenery here. Just call MoveAircraft() after this and let that reload the scenery. e.g.:

            //set the time/season
            this.hour.Value = Convert.ToByte(iHour);
            this.season.Value = 0;

Let me know if these ideas don't work, or don't do what you want, and I'll look into it some more.



Link to comment
Share on other sites

Thanks Paul for looking into this.  Bummer that FSX/P3D don't have that move aircraft ability built-in.  However based upon your suggestion, I tried this and it did indeed keep it to one load time:


            //set the time
            FSUIPCConnection.UTCDateTime = new DateTime(2018, 12, 25, 10, 0, 0);
            //Set the parameters for moving the plane
            // Set the OnGround flag
            bool onGround = false;
            // Set the heading (in degrees TRUE)
            double? heading = oPos.Heading_True;
            // IAS and Altitude set to null as we've set the OnGround flag
            double? ias = (int)oPos.Airspeed_IAS;
            FsAltitude? altitude = FsAltitude.FromFeet(oPos.Altitude);
            // Set level plane on the ground
            double? pitch = 4.21;
            double? bank = 0;
            // Call the method
            FSUIPCConnection.MoveAircraft(newPos, onGround, altitude, heading, pitch, bank, ias, true);


I'll have to write a convertor to get the move-to airport date/time into UTC, but that appears to be relatively trivial once you use the .NET TimeZoneInfo class.  I did have P3D lock up once right after the call and eventually crash so I'll need to test this a bunch to make sure that it will be reliable.  But at least this does save another scenery load.



Link to comment
Share on other sites

I'll have to mess with that function to see if it takes the LocalDateTime of where the plane is currently at or whether or not it will update it to the destination airport that the plane is being moved to.  With the date call right before the move call, it may not work out the way that I think it should.  The UTC time will work though.  I've got a database that I created as a dump from the MakeRunways program that I have georeferenced the airports lat/lon to determine all their country/state locales.  Getting the correct UTC won't be a big deal.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 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.