XPMP2
X-Plane multiplayer library 2 - using instancing
Namespaces | Macros | Typedefs | Functions | Variables
Aircraft.cpp File Reference

XPMP2::Aircraft represents an aircraft as managed by XPMP2. More...

#include "XPMP2.h"

Namespaces

 XPMP2
 

Macros

#define WARN_MODEL_NOT_FOUND   "Named CSL Model '%s' not found"
 
#define FATAL_MODE_S_OUT_OF_RGE   "_modeS_id (0x%06X) is out of range [0x%06X..0x%06X]"
 
#define FATAL_MODE_S_EXISTS   "_modeS_id (0x%06X) already exists"
 
#define FATAL_CREATE_INVALID   "Called Aircraft::Create() on already defined plane with _modeS_id (0x%06X)"
 
#define DEBUG_REPL_MODE_S   "Replaced duplicate _modeS_id 0x%06X with new unique value 0x%06X"
 
#define ERR_CREATE_INSTANCE   "Aircraft 0x%06X: Create Instance FAILED for CSL Model %s"
 
#define DEBUG_INSTANCE_CREATED   "Aircraft 0x%06X: Instance created of model %s for '%s'"
 
#define DEBUG_INSTANCE_DESTRYD   "Aircraft 0x%06X: Instance destroyed"
 
#define INFO_MODEL_CHANGE   "Aircraft 0x%06X: Changing model from %s to %s"
 
#define ERR_YPROBE   "Aircraft 0x%06X: Could not create Y-Probe for terrain testing!"
 
#define ERR_SET_INVALID   "Aircraft 0x%06X set INVALID"
 
#define WARN_PLANES_LEFT_EXIT   "Still %lu aircaft defined during shutdown! Plugin should destroy them prior to shutting down."
 
#define ERR_ADD_DATAREF_INIT   "Could not add dataRef %s, XPMP2 not yet initialized?"
 
#define ERR_ADD_DATAREF_PLANES   "Could add dataRef %s only if no aircraft are flying, but currently there are %lu aircraft."
 
#define ERR_WORKER_THREAD   "Can only be called from XP's main thread!"
 
#define DEBUG_DATAREF_ADDED   "Added dataRef %s as index %lu"
 

Typedefs

typedef std::map< std::string, Aircraft::wakeTyXPMP2::mapWakeTy
 

Functions

float XPMP2::obj_get_float (void *)
 
int XPMP2::obj_get_float_array (void *, float *, int, int inCount)
 See obj_get_float() More...
 
void XPMP2::AcInit ()
 Initialize the module. More...
 
void XPMP2::AcCleanup ()
 Grace cleanup, esp. remove all aircraft. More...
 
AircraftXPMP2::AcFindByID (XPMPPlaneID _id)
 Find aircraft by its plane ID, can return nullptr. More...
 
bool XPMP2::AcSetDefaultWakeData (const std::string &_wtc, const Aircraft::wakeTy &_wake)
 (Re)Define default wake turbulence values per WTC More...
 
size_t XPMPAddModelDataRef (const std::string &dataRef)
 Add a user-defined dataRef to the list of dataRefs supported by every plane. More...
 

Variables

XPLMFlightLoopID XPMP2::gFlightLoopID = nullptr
 The id of our flight loop callback. More...
 
std::vector< std::unique_ptr< std::string > > XPMP2::drStrings
 
std::vector< XPLMDataRef > XPMP2::ahDataRefs
 Registered dataRefs. More...
 

Detailed Description

XPMP2::Aircraft represents an aircraft as managed by XPMP2.

Note
This class bases on and is compatible to the XPCAircraft wrapper class provided with the original libxplanemp. In XPMP2, however, this class is not a wrapper but the actual means of managing aircraft. Hence, it includes a lot more members.
Author
Birger Hoppe

Macro Definition Documentation

◆ DEBUG_DATAREF_ADDED

#define DEBUG_DATAREF_ADDED   "Added dataRef %s as index %lu"

◆ DEBUG_INSTANCE_CREATED

#define DEBUG_INSTANCE_CREATED   "Aircraft 0x%06X: Instance created of model %s for '%s'"

◆ DEBUG_INSTANCE_DESTRYD

#define DEBUG_INSTANCE_DESTRYD   "Aircraft 0x%06X: Instance destroyed"

◆ DEBUG_REPL_MODE_S

#define DEBUG_REPL_MODE_S   "Replaced duplicate _modeS_id 0x%06X with new unique value 0x%06X"

◆ ERR_ADD_DATAREF_INIT

#define ERR_ADD_DATAREF_INIT   "Could not add dataRef %s, XPMP2 not yet initialized?"

◆ ERR_ADD_DATAREF_PLANES

#define ERR_ADD_DATAREF_PLANES   "Could add dataRef %s only if no aircraft are flying, but currently there are %lu aircraft."

◆ ERR_CREATE_INSTANCE

#define ERR_CREATE_INSTANCE   "Aircraft 0x%06X: Create Instance FAILED for CSL Model %s"

◆ ERR_SET_INVALID

#define ERR_SET_INVALID   "Aircraft 0x%06X set INVALID"

◆ ERR_WORKER_THREAD

#define ERR_WORKER_THREAD   "Can only be called from XP's main thread!"

◆ ERR_YPROBE

#define ERR_YPROBE   "Aircraft 0x%06X: Could not create Y-Probe for terrain testing!"

◆ FATAL_CREATE_INVALID

#define FATAL_CREATE_INVALID   "Called Aircraft::Create() on already defined plane with _modeS_id (0x%06X)"

◆ FATAL_MODE_S_EXISTS

#define FATAL_MODE_S_EXISTS   "_modeS_id (0x%06X) already exists"

◆ FATAL_MODE_S_OUT_OF_RGE

#define FATAL_MODE_S_OUT_OF_RGE   "_modeS_id (0x%06X) is out of range [0x%06X..0x%06X]"

◆ INFO_MODEL_CHANGE

#define INFO_MODEL_CHANGE   "Aircraft 0x%06X: Changing model from %s to %s"

◆ WARN_MODEL_NOT_FOUND

#define WARN_MODEL_NOT_FOUND   "Named CSL Model '%s' not found"

◆ WARN_PLANES_LEFT_EXIT

#define WARN_PLANES_LEFT_EXIT   "Still %lu aircaft defined during shutdown! Plugin should destroy them prior to shutting down."

Function Documentation

◆ XPMPAddModelDataRef()

size_t XPMPAddModelDataRef ( const std::string &  dataRef)

Add a user-defined dataRef to the list of dataRefs supported by every plane.

All planes created by XPMP2 define the same set of dataRefs. See XPMP2::DR_VALS for the definitions that come pre-defined with XPMP2. Here you can add more dataRefs that you want to set in your XPMP2::Aircraft::UpdatePosition() implementation.

Returns
The functions returns the array index you need to use in the XPMP2::Aircraft::v array to provide the actual value. Or 0 when an error occured.
Note
There is a duplication check: Adding an already existing dataRef, no matter if XPMP2-predefined or by the plugin will return the already existing index.
Can only be called while no plane exists as it influence the size of important data arrays. Returns 0 if called while planes exist.
Can only be called from XP's main thread as XPLM SDK functions are called. Returns 0 if called from a worker thread.
User-defined dataRefs are not transfered to the XPMP2 Remote Client for display on network-connected X-Plane instances.