XPMP2-Sample/XPMP2-Sample.cpp
void PlanesCreate ()
{
    // 1. New interface of XPMP2::Aircraft class
    if (!pSamplePlane) try {
        pSamplePlane = new SampleAircraft(PLANE_MODEL[gModelIdxBase][0],  // type
                                          PLANE_MODEL[gModelIdxBase][1],  // airline
                                          PLANE_MODEL[gModelIdxBase][2],  // livery
                                          0xABCDEF);                      // manually set Mode S id
    }
    catch (const XPMP2::XPMP2Error& e) {
        LogMsg("Could not create object of type SampleAircraft: %s", e.what());
        pSamplePlane = nullptr;
    }

    // 2. Subclassing the Legacy XPCAircraft class
    // Creating the plane can now (this is new in XPMP2) throw an exception
    if (!pLegacyPlane) try {
        pLegacyPlane = new LegacySampleAircraft(PLANE_MODEL[(gModelIdxBase+1)%3][0].c_str(),  // type
                                                PLANE_MODEL[(gModelIdxBase+1)%3][1].c_str(),  // airline
                                                PLANE_MODEL[(gModelIdxBase+1)%3][2].c_str(),  // livery
                                                0x123456);                                    // manually set Mode S id
    }
    catch (const XPMP2::XPMP2Error& e) {
        LogMsg("Could not create object of type LegacySampleAircraft: %s", e.what());
        pLegacyPlane = nullptr;
    }

    // 3. Using Standard Legacy C interface
    if (!hStdPlane)
        hStdPlane = XPMPCreatePlane(PLANE_MODEL[(gModelIdxBase+2)%3][0].c_str(),  // type
                                    PLANE_MODEL[(gModelIdxBase+2)%3][1].c_str(),  // airline
                                    PLANE_MODEL[(gModelIdxBase+2)%3][2].c_str(),  // livery
                                    CBPlaneData, NULL);

    // Put a checkmark in front of menu item if planes are visible
    XPLMCheckMenuItem(hMenu, 0, ArePlanesCreated()  ? xplm_Menu_Checked : xplm_Menu_Unchecked);
    XPLMCheckMenuItem(hMenu, 1, gbVisible           ? xplm_Menu_Checked : xplm_Menu_Unchecked);
}
/// Create our 3 planes (if they don't exist already)

Create our 3 planes (if they don't exist already)
Create our 3 planes ( if they don ' t exist already )
void PlanesCreate ()
{
    if (!pSamplePlane) try {
        pSamplePlane = new SampleAircraft(PLANE_MODEL[gModelIdxBase][0],  
                                          PLANE_MODEL[gModelIdxBase][1],  
                                          PLANE_MODEL[gModelIdxBase][2],  
                                          0xABCDEF);                      
    }
    catch (const XPMP2::XPMP2Error& e) {
        LogMsg("Could not create object of type SampleAircraft: %s", e.what());
        pSamplePlane = nullptr;
    }
    if (!pLegacyPlane) try {
        pLegacyPlane = new LegacySampleAircraft(PLANE_MODEL[(gModelIdxBase+1)%3][0].c_str(),  
                                                PLANE_MODEL[(gModelIdxBase+1)%3][1].c_str(),  
                                                PLANE_MODEL[(gModelIdxBase+1)%3][2].c_str(),  
                                                0x123456);                                    
    }
    catch (const XPMP2::XPMP2Error& e) {
        LogMsg("Could not create object of type LegacySampleAircraft: %s", e.what());
        pLegacyPlane = nullptr;
    }
    if (!hStdPlane)
        hStdPlane = XPMPCreatePlane(PLANE_MODEL[(gModelIdxBase+2)%3][0].c_str(),  
                                    PLANE_MODEL[(gModelIdxBase+2)%3][1].c_str(),  
                                    PLANE_MODEL[(gModelIdxBase+2)%3][2].c_str(),  
                                    CBPlaneData, NULL);
    XPLMCheckMenuItem(hMenu, 0, ArePlanesCreated()  ? xplm_Menu_Checked : xplm_Menu_Unchecked);
    XPLMCheckMenuItem(hMenu, 1, gbVisible           ? xplm_Menu_Checked : xplm_Menu_Unchecked);
}
void PlanesCreate ( ) { if ( ! pSamplePlane ) try { pSamplePlane = new SampleAircraft ( PLANE_MODEL [ gModelIdxBase ] [ 0 ] , PLANE_MODEL [ gModelIdxBase ] [ 1 ] , PLANE_MODEL [ gModelIdxBase ] [ 2 ] , 0xABCDEF ) ; } catch ( const XPMP2 :: XPMP2Error & e ) { LogMsg ( " " , e . what ( ) ) ; pSamplePlane = nullptr ; } if ( ! pLegacyPlane ) try { pLegacyPlane = new LegacySampleAircraft ( PLANE_MODEL [ ( gModelIdxBase + 1 ) % 3 ] [ 0 ] . c_str ( ) , PLANE_MODEL [ ( gModelIdxBase + 1 ) % 3 ] [ 1 ] . c_str ( ) , PLANE_MODEL [ ( gModelIdxBase + 1 ) % 3 ] [ 2 ] . c_str ( ) , 0x123456 ) ; } catch ( const XPMP2 :: XPMP2Error & e ) { LogMsg ( " " , e . what ( ) ) ; pLegacyPlane = nullptr ; } if ( ! hStdPlane ) hStdPlane = XPMPCreatePlane ( PLANE_MODEL [ ( gModelIdxBase + 2 ) % 3 ] [ 0 ] . c_str ( ) , PLANE_MODEL [ ( gModelIdxBase + 2 ) % 3 ] [ 1 ] . c_str ( ) , PLANE_MODEL [ ( gModelIdxBase + 2 ) % 3 ] [ 2 ] . c_str ( ) , CBPlaneData , NULL ) ; XPLMCheckMenuItem ( hMenu , 0 , ArePlanesCreated ( ) ? xplm_Menu_Checked : xplm_Menu_Unchecked ) ; XPLMCheckMenuItem ( hMenu , 1 , gbVisible ? xplm_Menu_Checked : xplm_Menu_Unchecked ) ; }
Create our 3 planes (if they don't exist already)
Create our 3 planes ( if they don ' t exist already )
// 1. New interface of XPMP2::Aircraft class
 // type
 // airline
 // livery
 // manually set Mode S id
 // 2. Subclassing the Legacy XPCAircraft class
 // Creating the plane can now (this is new in XPMP2) throw an exception
 // type
 // airline
 // livery
 // manually set Mode S id
 // 3. Using Standard Legacy C interface
 // type
 // airline
 // livery
 // Put a checkmark in front of menu item if planes are visible
