• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Read all Waypoints from player flight plan

Messages
8
Country
switzerland
Using SimConnect, "AI Waypoint List" seems to be the equivalent for AI but how to get a list of all waypoints from the players flight plan? Or is there another approach? I need to put markers on a map for each waypoint so I need lat/lon for each of them.

Thanks!
 
Messages
8
Country
switzerland
@DragonflightDesign sorry but I'm only used to SimConnect... how can I read data from XML files? Which XML files? Or how would you do it in C? Where would you read it from?

Can you point me in a direction?
 

DragonflightDesign

Resource contributor
Messages
1,038
Country
northernireland
If you're using SimConnect then you must be using C or C++. SimConnect will give you the name of the current flightplan. Once you know that, you can open the flightplan using fopen_s etc. and parse out the lines in the flightplan. The waypoint lines all start 'waypoint.X='. After that, you can parse the line using strtok and chr(44) to break it up into sections..
 
Messages
2,044
Country
us-ohio
No SimConnect does not expose the entire flight plan... unless they added new variables for that. Maybe checking the variable list in the SDK?
 
Messages
2,044
Country
us-ohio
There is no documentation regarding the flight plan files. Where FS is installed is found from a registry entry, do a search of FSDevelolper for the install directory/folder.
 

DragonflightDesign

Resource contributor
Messages
1,038
Country
northernireland
How to get the sim type:
Code:
int simVer=0;                                    // FS version 9 = FS9, 10 = FSX, 8 = P3D
//**************************************************************************
//Get simulator version
//**************************************************************************
void getSimVer()
{
    WIN32_FIND_DATA ffd; // file information struct
    HANDLE sh;
    char searchPath[32];

    strncpy(searchPath,"prepar3d.exe\0",13);
    sh=FindFirstFile(searchPath,&ffd);
    if(sh==INVALID_HANDLE_VALUE)
    {
        strncpy(searchPath,"fsx.exe\0",8);
        sh=FindFirstFile(searchPath,&ffd);
        if(sh==INVALID_HANDLE_VALUE)
        {
            strncpy(searchPath,"fs9.exe\0",8);
            sh=FindFirstFile(searchPath,&ffd);
            if(sh==INVALID_HANDLE_VALUE)simVer=-1;
            else simVer=9;
        }
        else simVer=10;
    }
    else simVer=8;                // Random designator for Prepar3D
    return;
}
 

DragonflightDesign

Resource contributor
Messages
1,038
Country
northernireland
How to find the sim installtion path:
Code:
//**************************************************************************
// Get simulator path - preceed by getSimVer() to ensure the version is set
//**************************************************************************
void getSimPath()
{
    char szFileName[MAX_PATH];
    int ret = 0;

    if (simVer != 8 && simVer != 9 && simVer != 10)getSimVer();

    ret = GetModuleFileName(NULL, szFileName, MAX_PATH);
    if (simVer == 8)getLeft(szFileName, simPath, ret - 13);    // Prepar3D.exe
    else getLeft(szFileName, simPath, ret - 8);                        // FSX / FS9

    return;
}

Support function getLeft(). (Ed will probably hate this :D )

Code:
void getLeft(char *fullString,char *leftChars,int noChars)
{
    int x=0;
    int StringLength=0;

// Sanity check
    if (fullString != NULL && leftChars != NULL && noChars)
    {
        StringLength=(int)strlen(fullString);
        //Ensure that we don't try to return more characters than actually exist
        if (noChars > StringLength)noChars = StringLength;
        //Get Left
        for (x = 0; x < noChars; x++)
            *leftChars++ = *fullString++;
        // Terminate the string
        *leftChars++ = '\0';
    }
    return;
}

You can get the path to the user's flight files/flightplans by using the SimConnect call:

Code:
void OnRecvSystemState(SIMCONNECT_RECV_SYSTEM_STATE *pData)
{
    if (pData->dwRequestID)
    {
        switch (pData->dwRequestID)
        {
            case REQUEST_FLIGHT_LOADED:
                strncpy_s(CURRENT_FLIGHT, MAX_PATH, pData->szString, sizeof(pData->szString));
            break;
        }
    }
}
Remove the name of the flight from the end of CURRENT_FLIGHT and you have the path.
 
Last edited:
Top