XPMP2
X-Plane multiplayer library 2 - using instancing
|
Initialization and general control functions for XPMP2. More...
Namespaces | |
XPMP2 | |
Macros | |
#define | ERR_RSRC_DIR_INVALID "Resource directory too short: %s" |
#define | ERR_RSRC_DIR_UNAVAIL "Resource directory '%s' does not exist!" |
#define | ERR_RSRC_FILE_UNAVAIL "File '%s' is missing in resource directory '%s'" |
#define | INFO_DEFAULT_ICAO "Default ICAO aircraft type now is %s" |
#define | INFO_CAR_ICAO "Ground vehicle ICAO type now is %s" |
#define | INFO_LOAD_CSL_PACKAGE "Loading CSL package from %s" |
Functions | |
const char * | XPMP2::XPMPValidateResourceFiles (const char *resourceDir) |
Validate all required files are available in the resource directory. More... | |
const char * | XPMPMultiplayerInitLegacyData (const char *inCSLFolder, const char *inPluginName, const char *resourceDir, XPMPIntPrefsFuncTy inIntPrefsFunc, const char *inDefaultICAO, const char *inPluginLogAcronym) |
Deprecated legacy initialization of XPMP2. More... | |
const char * | XPMPMultiplayerInit (const char *inPluginName, const char *resourceDir, XPMPIntPrefsFuncTy inIntPrefsFunc, const char *inDefaultICAO, const char *inPluginLogAcronym) |
Initializes the XPMP2 library. This shall be your first call to the library. More... | |
void | XPMPSetPluginName (const char *inPluginName, const char *inPluginLogAcronym) |
Overrides the plugin's name to be used in Log output. More... | |
void | XPMPMultiplayerCleanup () |
Clean up the multiplayer library. More... | |
const char * | XPMPMultiplayerOBJ7SupportEnable (const char *) |
Used to set the light textures for old OBJ7 models. More... | |
const char * | XPMPLoadCSLPackage (const char *inCSLFolder) |
Loads CSL packages from the given folder, searching up to 5 folder levels deep. More... | |
void | XPMPLoadPlanesIfNecessary () |
Legacy function only provided for backwards compatibility. Does not actually do anything. More... | |
int | XPMPGetNumberOfInstalledModels () |
Returns the number of loaded CSL models. More... | |
void | XPMPGetModelInfo (int inIndex, const char **outModelName, const char **outIcao, const char **outAirline, const char **outLivery) |
Fetch information about a CSL model identified by an index. More... | |
void | XPMPGetModelInfo2 (int inIndex, std::string &outModelName, std::string &outIcao, std::string &outAirline, std::string &outLivery) |
Fetch information about a CSL model identified by an index. More... | |
int | XPMPModelMatchQuality (const char *inICAO, const char *inAirline, const char *inLivery) |
Tests model match quality based on the given parameters. More... | |
bool | XPMPIsICAOValid (const char *inICAO) |
Is inICAO a valid ICAO aircraft type designator? More... | |
XPMPPlaneID | XPMPCreatePlane (const char *inICAOCode, const char *inAirline, const char *inLivery, XPMPPlaneData_f inDataFunc, void *inRefcon, XPMPPlaneID inModeS_id) |
Creates a new plane. More... | |
XPMPPlaneID | XPMPCreatePlaneWithModelName (const char *inModelName, const char *inICAOCode, const char *inAirline, const char *inLivery, XPMPPlaneData_f inDataFunc, void *inRefcon, XPMPPlaneID inModeS_id) |
Creates a new plane, providing a specific CSL model name. More... | |
void | XPMPDestroyPlane (XPMPPlaneID _id) |
[Deprecated] Removes a plane previously created with XPMPCreatePlane() More... | |
void | XPMPSetPlaneVisibility (XPMPPlaneID _id, bool _bVisible) |
Show/Hide the aircraft temporarily without destroying the object. More... | |
int | XPMPChangePlaneModel (XPMPPlaneID _id, const char *inICAO, const char *inAirline, const char *inLivery) |
Perform model matching again and change the CSL model to the resulting match. More... | |
int | XPMPGetPlaneModelName (XPMPPlaneID inPlaneID, char *outTxtBuf, int outTxtBufSize) |
Return the name of the model, with which the given plane is rendered. More... | |
void | XPMPGetPlaneICAOAndLivery (XPMPPlaneID inPlane, char *outICAOCode, char *outLivery) |
Returns ICAO aircraft type designator and livery of the given plane. More... | |
XPMPPlaneCallbackResult | XPMPGetPlaneData (XPMPPlaneID, XPMPPlaneDataType, void *) |
Unsupported, don't use. More... | |
int | XPMPGetPlaneModelQuality (XPMPPlaneID _inPlane) |
Returns the match quality of the currently used model, or -1 if inPlane is invalid. More... | |
long | XPMPCountPlanes () |
Returns the number of planes in existence. More... | |
XPMPPlaneID | XPMPGetNthPlane (long index) |
Returns the plane ID of the Nth plane. More... | |
XPMP2::Aircraft * | XPMPGetAircraft (XPMPPlaneID _id) |
Returns the underlying aircraft object, or nullptr if _id is invalid. More... | |
void | XPMPSetDefaultPlaneICAO (const char *_acIcaoType, const char *_carIcaoType) |
Define default aircraft and ground vehicle ICAO types. More... | |
void | XPMPRegisterPlaneNotifierFunc (XPMPPlaneNotifier_f inFunc, void *inRefcon) |
Registers a callback, which is called when one of the events defined in XPMPPlaneNotification happens. More... | |
void | XPMPUnregisterPlaneNotifierFunc (XPMPPlaneNotifier_f inFunc, void *inRefcon) |
Unregisters a notification callback. Both function pointer and refcon must match what was registered. More... | |
void | XPMP2::XPMPSendNotification (const Aircraft &plane, XPMPPlaneNotification _notification) |
Send a notification to all observers. More... | |
void | XPMPSetPlaneRenderer (XPMPRenderPlanes_f, void *) |
The original libxplanemp allowed to override rendering; no longer supported. More... | |
void | XPMPDumpOneCycle (void) |
Legacy debug-support function, no longer supported. More... | |
void | XPMPInitDefaultPlaneRenderer (void) |
Was an internal libxplanemp functions. More... | |
void | XPMPDefaultPlaneRenderer (int) |
Was an internal libxplanemp functions. More... | |
void | XPMPDeinitDefaultPlaneRenderer (void) |
Was an internal libxplanemp functions. More... | |
Initialization and general control functions for XPMP2.
#define ERR_RSRC_DIR_INVALID "Resource directory too short: %s" |
#define ERR_RSRC_DIR_UNAVAIL "Resource directory '%s' does not exist!" |
#define ERR_RSRC_FILE_UNAVAIL "File '%s' is missing in resource directory '%s'" |
#define INFO_CAR_ICAO "Ground vehicle ICAO type now is %s" |
#define INFO_DEFAULT_ICAO "Default ICAO aircraft type now is %s" |
#define INFO_LOAD_CSL_PACKAGE "Loading CSL package from %s" |
int XPMPChangePlaneModel | ( | XPMPPlaneID | inPlaneID, |
const char * | inICAOCode, | ||
const char * | inAirline, | ||
const char * | inLivery | ||
) |
Perform model matching again and change the CSL model to the resulting match.
inPlaneID | Which plane to change? |
inICAOCode | ICAO aircraft type designator, like 'A320', 'B738', 'C172' |
inAirline | ICAO airline code, like 'BAW', 'DLH', can be an empty string |
inLivery | Special livery designator, can be an empty string |
inPlaneID
is invalid long XPMPCountPlanes | ( | void | ) |
Returns the number of planes in existence.
XPMPPlaneID XPMPCreatePlane | ( | const char * | inICAOCode, |
const char * | inAirline, | ||
const char * | inLivery, | ||
XPMPPlaneData_f | inDataFunc, | ||
void * | inRefcon, | ||
XPMPPlaneID | inModeS_id = 0 |
||
) |
Creates a new plane.
Effectively calls XPMPCreatePlaneWithModelName() with inModelName = nullptr
inICAOCode | ICAO aircraft type designator, like 'A320', 'B738', 'C172' |
inAirline | ICAO airline code, like 'BAW', 'DLH', can be an empty string |
inLivery | Special livery designator, can be an empty string |
inDataFunc | Callback function called by XPMP2 to fetch updated data |
inRefcon | A refcon value passed back to you in all calls to the inDataFunc |
inModeS_id | (optional) Unique identification of the plane [0x01..0xFFFFFF], e.g. the 24bit mode S transponder code. XPMP2 assigns an arbitrary unique number of not given |
XPMPPlaneID XPMPCreatePlaneWithModelName | ( | const char * | inModelName, |
const char * | inICAOCode, | ||
const char * | inAirline, | ||
const char * | inLivery, | ||
XPMPPlaneData_f | inDataFunc, | ||
void * | inRefcon, | ||
XPMPPlaneID | inModeS_id = 0 |
||
) |
Creates a new plane, providing a specific CSL model name.
inModelName | CSL Model name (id) to use, or nullptr if normal matching using the next 3 parameters shall be applied |
inICAOCode | ICAO aircraft type designator, like 'A320', 'B738', 'C172' |
inAirline | ICAO airline code, like 'BAW', 'DLH', can be an empty string |
inLivery | Special livery designator, can be an empty string |
inDataFunc | Callback function called by XPMP2 to fetch updated data |
inRefcon | A refcon value passed back to you in all calls to the inDataFunc |
inModeS_id | (optional) Unique identification of the plane [0x01..0xFFFFFF], e.g. the 24bit mode S transponder code. XPMP2 assigns an arbitrary unique number of not given |
void XPMPDefaultPlaneRenderer | ( | int | is_blend | ) |
Was an internal libxplanemp functions.
void XPMPDeinitDefaultPlaneRenderer | ( | void | ) |
Was an internal libxplanemp functions.
void XPMPDestroyPlane | ( | XPMPPlaneID | _id | ) |
[Deprecated] Removes a plane previously created with XPMPCreatePlane()
void XPMPDumpOneCycle | ( | void | ) |
Legacy debug-support function, no longer supported.
XPMP2::Aircraft* XPMPGetAircraft | ( | XPMPPlaneID | _id | ) |
Returns the underlying aircraft object, or nullptr
if _id
is invalid.
void XPMPGetModelInfo | ( | int | inIndex, |
const char ** | outModelName, | ||
const char ** | outIcao, | ||
const char ** | outAirline, | ||
const char ** | outLivery | ||
) |
Fetch information about a CSL model identified by an index.
inIndex | Number between 0 and `XPMPGetNumberOfInstalledModels()-1 | |
[out] | outModelName | Receives pointer to model name (id). Optional, can be nullptr. |
[out] | outIcao | Receives pointer to ICAO aircraft type designator. Optional, can be nullptr . |
[out] | outAirline | Receives pointer to ICAO airline code. Optional, can be nullptr . |
[out] | outLivery | Receives pointer to special livery string. Optional, can be nullptr . |
void XPMPGetModelInfo2 | ( | int | inIndex, |
std::string & | outModelName, | ||
std::string & | outIcao, | ||
std::string & | outAirline, | ||
std::string & | outLivery | ||
) |
Fetch information about a CSL model identified by an index.
inIndex | Number between 0 and `XPMPGetNumberOfInstalledModels()-1 | |
[out] | outModelName | Receives model name (id) |
[out] | outIcao | Receives ICAO aircraft designator |
[out] | outAirline | Receives ICAO airline code |
[out] | outLivery | Receives special livery string |
XPMPPlaneID XPMPGetNthPlane | ( | long | index | ) |
Returns the plane ID of the Nth plane.
int XPMPGetNumberOfInstalledModels | ( | ) |
Returns the number of loaded CSL models.
XPMPPlaneCallbackResult XPMPGetPlaneData | ( | XPMPPlaneID | inPlane, |
XPMPPlaneDataType | inDataType, | ||
void * | outData | ||
) |
Unsupported, don't use.
xpmpData_Unavailable
void XPMPGetPlaneICAOAndLivery | ( | XPMPPlaneID | inPlane, |
char * | outICAOCode, | ||
char * | outLivery | ||
) |
Returns ICAO aircraft type designator and livery of the given plane.
int XPMPGetPlaneModelName | ( | XPMPPlaneID | inPlaneID, |
char * | outTxtBuf, | ||
int | outTxtBufSize | ||
) |
Return the name of the model, with which the given plane is rendered.
inPlaneID | Identifies the plane | |
[out] | outTxtBuf | (optional) Points to a character array to hold the model name. The returned C string is guaranteed to be zero-terminated. Pass in NULL to just receive the string's length |
outTxtBufSize | Size of that buffer |
inPlaneID
is invalid int XPMPGetPlaneModelQuality | ( | XPMPPlaneID | _inPlane | ) |
Returns the match quality of the currently used model, or -1
if inPlane
is invalid.
void XPMPInitDefaultPlaneRenderer | ( | void | ) |
Was an internal libxplanemp functions.
bool XPMPIsICAOValid | ( | const char * | inICAO | ) |
Is inICAO
a valid ICAO aircraft type designator?
const char* XPMPLoadCSLPackage | ( | const char * | inCSLFolder | ) |
Loads CSL packages from the given folder, searching up to 5 folder levels deep.
This function mainly searches the given folder for packages. It traverses all folders in search for xsb_aircraft.txt
files. It will find all xsb_aircraft.txt
files situated at or below the given root path, up to 5 levels deep.
As soon as such a file is found it is read and processed. Depth search then ends. (But searching parallel folders may still continue.)
The xsb_aircraft.txt
is loaded and processed. Duplicate models (by package and CSL model name, tags EXPORT_NAME
and OBJ8_AIRCRAFT
) are ignored. For others the existence of the .obj
file is validated, but not the existence of files in turn needed by the .obj
file, like textures. If validated successfully the model is added to an internal catalogue.
Actual loading of objects is done later and asynchronously only when needed during aircraft creation.
inCSLFolder | Root folder to start the search. |
void XPMPLoadPlanesIfNecessary | ( | ) |
Legacy function only provided for backwards compatibility. Does not actually do anything.
int XPMPModelMatchQuality | ( | const char * | inICAO, |
const char * | inAirline, | ||
const char * | inLivery | ||
) |
Tests model match quality based on the given parameters.
inICAO | ICAO aircraft type designator, optional, can be nullptr |
inAirline | ICAO airline code, optional, can be nullptr |
inLivery | Special livery text, optional, can be nullptr |
void XPMPMultiplayerCleanup | ( | ) |
const char* XPMPMultiplayerInit | ( | const char * | inPluginName, |
const char * | resourceDir, | ||
XPMPIntPrefsFuncTy | inIntPrefsFunc = nullptr , |
||
const char * | inDefaultICAO = nullptr , |
||
const char * | inPluginLogAcronym = nullptr |
||
) |
Initializes the XPMP2 library. This shall be your first call to the library.
inPluginName | Your plugin's name, mainly used as map layer name and for logging |
resourceDir | The directory where XPMP2 finds all required supplemental files (Doc8643.txt , MapIcons.png , related.txt , optionally Obj8DataRefs.txt ) |
inIntPrefsFunc | (optional) A pointer to a callback function providing integer config values. See XPMPIntPrefsFuncTy for details. |
inDefaultICAO | (optional) A fallback aircraft type if no type can be deduced otherwise for an aircraft. |
inPluginLogAcronym | (optional) A short text to be used in log output. If not given then inPluginName is used also for this purpose. |
Assume that this is XP's main thread
const char* XPMPMultiplayerInitLegacyData | ( | const char * | inCSLFolder, |
const char * | inPluginName, | ||
const char * | resourceDir, | ||
XPMPIntPrefsFuncTy | inIntPrefsFunc = nullptr , |
||
const char * | inDefaultICAO = nullptr , |
||
const char * | inPluginLogAcronym = nullptr |
||
) |
Deprecated legacy initialization of XPMP2.
Effectively calls, in this order, XPMPMultiplayerInit() and XPMPLoadCSLPackage().
const char* XPMPMultiplayerOBJ7SupportEnable | ( | const char * | inTexturePath | ) |
Used to set the light textures for old OBJ7 models.
void XPMPRegisterPlaneNotifierFunc | ( | XPMPPlaneNotifier_f | inFunc, |
void * | inRefcon | ||
) |
Registers a callback, which is called when one of the events defined in XPMPPlaneNotification happens.
inFunc | Pointer to your callback function |
inRefcon | A refcon passed through to your callback |
void XPMPSetDefaultPlaneICAO | ( | const char * | _acIcaoType, |
const char * | _carIcaoType = nullptr |
||
) |
Define default aircraft and ground vehicle ICAO types.
_acIcaoType | Default ICAO aircraft type designator, used when matching returns nothing |
_carIcaoType | Type used to identify ground vehicels (internally defaults to "ZZZC") |
void XPMPSetPlaneRenderer | ( | XPMPRenderPlanes_f | inRenderer, |
void * | inRef | ||
) |
The original libxplanemp allowed to override rendering; no longer supported.
void XPMPSetPlaneVisibility | ( | XPMPPlaneID | _id, |
bool | _bVisible | ||
) |
Show/Hide the aircraft temporarily without destroying the object.
void XPMPSetPluginName | ( | const char * | inPluginName, |
const char * | inPluginLogAcronym = nullptr |
||
) |
Overrides the plugin's name to be used in Log output.
The same as providing a plugin name with XPMPMultiplayerInit(). If no name is provided, it defaults to the plugin's name as set in XPluginStart().
XPMP_CLIENT_LONGNAME
needed in libxplanemp
. inPluginName | Your plugin's name, used as map layer name, and as folder name under Aircraft |
inPluginLogAcronym | (optional) A short text to be used in log output. If not given then inPluginName is used also for this purpse. |
void XPMPUnregisterPlaneNotifierFunc | ( | XPMPPlaneNotifier_f | inFunc, |
void * | inRefcon | ||
) |
Unregisters a notification callback. Both function pointer and refcon must match what was registered.
inFunc | Pointer to your callback function |
inRefcon | A refcon passed through to your callback |