XPMP2
X-Plane multiplayer library 2 - using instancing
Classes | Typedefs | Enumerations | Functions | Variables
XPMP2 Namespace Reference

Classes

struct  CSLModelInfo_t
 Collates some information on the CSL model. More...
 
class  Aircraft
 Actual representation of all aircraft in XPMP2. More...
 
class  XPMP2Error
 XPMP2 Exception class, e.g. thrown if there are no CSL models or duplicate modeS_ids when creating an Aircraft. More...
 
struct  RemoteDataRefPackTy
 Definition for how to map dataRef values to (u)int8, ie. to an integer range of 8 bits. More...
 
struct  RemoteMsgBaseTy
 Message header, identical for all message types. More...
 
struct  RemoteMsgBeaconTy
 "Beacon of Interest", ie. some message on the multicast just to wake up sender More...
 
struct  RemoteMsgSettingsTy
 Settings message, identifying a sending plugin, regularly providing its settings. More...
 
struct  RemoteAcDetailTy
 A/C details, packed into an array message. More...
 
struct  RemoteMsgAcDetailTy
 A/C detail message, has an inherited header plus an array of XPMP2::RemoteAcDetailTy elements. More...
 
struct  RemoteAcPosUpdateTy
 A/C Position updates based on global coordinates. More...
 
struct  RemoteMsgAcPosUpdateTy
 A/C detail message, has an inherited header plus an array of XPMP2::RemoteAcDetailTy elements. More...
 
struct  RemoteAcAnimTy
 A/C animation dataRef changes. More...
 
struct  RemoteMsgAcAnimTy
 A/C animation dataRef message, has an inherited header plus an array of variable sized XPMP2::RemoteAcAnimTy elements. More...
 
struct  RemoteAcRemoveTy
 A/C Removal only includes the plane id, structure required for msgSize() function. More...
 
struct  RemoteMsgAcRemoveTy
 A/C removal message, an array of plane ids. More...
 
struct  RemoteCBFctTy
 Function prototypes for callback functions to handle the received messages. More...
 
struct  multiDataRefsTy
 Keeps the dataRef handles for one of the up to 19 legacy AI/Multiplayer slots ("sim/multiplayer/position") More...
 
struct  infoDataRefsTy
 Keeps the dataRef handles for one of the up to 63 shared data slots ("sim/multiplayer/position/plane#...") More...
 
union  TcasLightsTy
 A structure simplifying communicaton with sim/cockpit2/tcas/targets/position/lights. More...
 
class  LegacyAircraft
 This class helps creating aircraft via the legacy global functions. It provides standard implementations of the abstract callbacks. More...
 
class  CSLObj
 One .obj file of a CSL model (of which it can have multiple) More...
 
class  CSLModel
 Represetns a CSL model as it is saved on disk. More...
 
class  NetRuntimeError
 Exception raised by XPMP2::SocketNetworking objects. More...
 
class  SocketNetworking
 Base class for any socket-based networking. More...
 
class  UDPReceiver
 Receives UDP messages. More...
 
class  UDPMulticast
 UDP Multicast, always binding to INADDR_ANY. More...
 
class  TCPConnection
 Listens to TCP connections and opens a session socket upon connect. More...
 
struct  InetAddrTy
 Numerical IP address, used for both ipv4 and ipv6, for ease of handling. More...
 
struct  Doc8643
 Represents a line in the Doc8643.txt file, of which we use only classification and WTC. More...
 
struct  Obj8DataRefs
 A pair of strings, first one to search for, second one to replace it with. More...
 
struct  RemoteAcDetailTy_v0
 Version 0 A/C details, packed into an array message. More...
 
struct  RemoteMsgAcDetailTy_v0
 Version 0 A/C detail message, has an inherited header plus an array of XPMP2::RemoteAcDetailTy elements. More...
 
struct  RmtAcCacheTy
 Holds a copy of some aircraft data as was sent out last. More...
 
class  RmtDataBaseTy
 Base structure for passing information from XP's main thread to the multicast thread. More...
 
class  RmtDataEnqeueTy
 Passing information about any data type (like a/c full detail message); the data is contained as copy. More...
 
class  RmtDataAcAnimTy
 Animation dataRef requires a special queue data type as each msg element is already of variable length. More...
 
class  RmtMsgBufTy
 Helper class to manage the temporary buffers in which the network message are put together. More...
 
struct  XPMPPlaneNotifierTy
 Stores the function and refcon pointer for plane creation/destrcution notifications. More...
 
struct  GlobVars
 All global config settings and variables are kept in one structure for convenient access and central definition. More...
 
union  RmtDataAcAnimTy.__unnamed4__
 

Typedefs

typedef std::map< float, XPMPPlaneIDmapAcByDistTy
 Map of Aircrafts, sorted by (priority-biased) distance. More...
 
typedef std::map< XPMPPlaneID, Aircraft * > mapAcTy
 Map of all aircraft, key is tthe plane id. More...
 
typedef std::map< std::string, int > mapStrIntTy
 a map of a text and a counter More...
 
typedef std::map< std::string, std::string > mapCSLPackageTy
 Map of CSLPackages: Maps an id to the base path (path ends on forward slash) More...
 
typedef std::list< CSLObjlistCSLObjTy
 List of objects. More...
 
typedef std::pair< std::string, std::string > pairOfStrTy
 
typedef std::map< std::string, CSLModelmapCSLModelTy
 Map of CSLModels (owning the object), ordered by related group / type. More...
 
typedef std::multimap< unsigned long, std::pair< CSLModel *, const CSLModel::MatchCritTy * > > mmapCSLModelPTy
 Multimap of references to CSLModels and match criteria for matching purposes. More...
 
typedef std::map< std::string, XPLMMapLayerID > mapMapLayerIDTy
 A map holding our layer identifier, indexed by the map's name. More...
 
typedef int SOCKET
 Windows defines SOCKET, so we define it for non-Windows manually. More...
 
typedef std::map< std::string, int > mapRelatedTy
 Map of group membership: ICAO a/c type maps to line in related.txt. More...
 
typedef std::map< std::string, Doc8643mapDoc8643Ty
 Map of Doc8643 information, key is the (icao) type code. More...
 
typedef std::list< Obj8DataRefslistObj8DataRefsTy
 a list of Obj8DataRefs definitions More...
 
typedef std::map< XPMPPlaneID, RmtAcCacheTymapRmtAcCacheTy
 Defines a map with the plane id as key and the aboce cache structure as payload. More...
 
typedef std::unique_ptr< RmtDataBaseTyptrRmtDataBaseTy
 Smart pointer to XPMP2::RmtDataBaseTy by which we manage objects of this and derived types. More...
 
typedef std::queue< ptrRmtDataBaseTy, std::list< ptrRmtDataBaseTy > > queueRmtDataTy
 A queue managing the information objects, used to transfer data between main thread and network thread. More...
 
typedef RmtDataEnqeueTy< RemoteAcDetailTy, RMT_MSG_AC_DETAILEDRmtDataAcDetailTy
 A/C Detail queue type. More...
 
typedef RmtDataEnqeueTy< RemoteAcPosUpdateTy, RMT_MSG_AC_POS_UPDATERmtDataAcPosUpdateTy
 A/C Position Update queue type. More...
 
typedef RmtDataEnqeueTy< RemoteAcRemoveTy, RMT_MSG_AC_REMOVERmtDataAcRemoveTy
 A/C Removal queue type. More...
 
typedef std::unique_ptr< RmtDataAcAnimTyptrRmtDataAcAnimTy
 Smart pointer to XPMP2::RmtDataAcAnimTy. More...
 
typedef std::list< XPMPPlaneNotifierTylistXPMPPlaneNotifierTy
 

Enumerations

enum  DR_VALS : std::uint8_t {
  V_CONTROLS_GEAR_RATIO = 0 , V_CONTROLS_NWS_RATIO , V_CONTROLS_FLAP_RATIO , V_CONTROLS_SPOILER_RATIO ,
  V_CONTROLS_SPEED_BRAKE_RATIO , V_CONTROLS_SLAT_RATIO , V_CONTROLS_WING_SWEEP_RATIO , V_CONTROLS_THRUST_RATIO ,
  V_CONTROLS_YOKE_PITCH_RATIO , V_CONTROLS_YOKE_HEADING_RATIO , V_CONTROLS_YOKE_ROLL_RATIO , V_CONTROLS_THRUST_REVERS ,
  V_CONTROLS_TAXI_LITES_ON , V_CONTROLS_LANDING_LITES_ON , V_CONTROLS_BEACON_LITES_ON , V_CONTROLS_STROBE_LITES_ON ,
  V_CONTROLS_NAV_LITES_ON , V_GEAR_NOSE_GEAR_DEFLECTION_MTR , V_GEAR_TIRE_VERTICAL_DEFLECTION_MTR , V_GEAR_TIRE_ROTATION_ANGLE_DEG ,
  V_GEAR_TIRE_ROTATION_SPEED_RPM , V_GEAR_TIRE_ROTATION_SPEED_RAD_SEC , V_ENGINES_ENGINE_ROTATION_ANGLE_DEG , V_ENGINES_ENGINE_ROTATION_SPEED_RPM ,
  V_ENGINES_ENGINE_ROTATION_SPEED_RAD_SEC , V_ENGINES_PROP_ROTATION_ANGLE_DEG , V_ENGINES_PROP_ROTATION_SPEED_RPM , V_ENGINES_PROP_ROTATION_SPEED_RAD_SEC ,
  V_ENGINES_THRUST_REVERSER_DEPLOY_RATIO , V_ENGINES_ENGINE_ROTATION_ANGLE_DEG1 , V_ENGINES_ENGINE_ROTATION_ANGLE_DEG2 , V_ENGINES_ENGINE_ROTATION_ANGLE_DEG3 ,
  V_ENGINES_ENGINE_ROTATION_ANGLE_DEG4 , V_ENGINES_ENGINE_ROTATION_SPEED_RPM1 , V_ENGINES_ENGINE_ROTATION_SPEED_RPM2 , V_ENGINES_ENGINE_ROTATION_SPEED_RPM3 ,
  V_ENGINES_ENGINE_ROTATION_SPEED_RPM4 , V_ENGINES_ENGINE_ROTATION_SPEED_RAD_SEC1 , V_ENGINES_ENGINE_ROTATION_SPEED_RAD_SEC2 , V_ENGINES_ENGINE_ROTATION_SPEED_RAD_SEC3 ,
  V_ENGINES_ENGINE_ROTATION_SPEED_RAD_SEC4 , V_MISC_TOUCH_DOWN , V_COUNT
}
 The dataRefs provided by XPMP2 to the CSL models. More...
 
enum  RemoteMsgTy : std::uint8_t {
  RMT_MSG_INTEREST_BEACON = 0 , RMT_MSG_SEND , RMT_MSG_SETTINGS , RMT_MSG_AC_DETAILED ,
  RMT_MSG_AC_POS_UPDATE , RMT_MSG_AC_ANIM , RMT_MSG_AC_REMOVE
}
 Message type. More...
 
enum  RemoteStatusTy : unsigned {
  REMOTE_OFF = 0 , REMOTE_SEND_WAITING , REMOTE_SENDING , REMOTE_RECV_WAITING ,
  REMOTE_RECEIVING
}
 State of remote communcations. More...
 
enum  ObjLoadStateTy {
  OLS_INVALID = -1 , OLS_UNAVAIL = 0 , OLS_COPYING , OLS_LOADING ,
  OLS_AVAILABLE
}
 State of the X-Plane object: Is it being loaded or available? More...
 
enum  RemoteCfgTy : int { REMOTE_CFG_OFF = -1 , REMOTE_CFG_AUTO = 0 , REMOTE_CFG_ON = 1 }
 Configuration for remote communications support. More...
 
enum  logLevelTy {
  logDEBUG = 0 , logINFO , logWARN , logERR ,
  logFATAL , logMSG
}
 Logging level. More...
 

Functions

AircraftAcFindByID (XPMPPlaneID _id)
 Find aircraft by its plane ID, can return nullptr. More...
 
std::uint16_t PJWHash16 (const char *s)
 Produces a reproducible(!) hash value for strings. More...
 
CSLModelCSLModelByPkgShortId (std::uint16_t _pkgHash, const std::string &_shortId)
 Find a model by package name hash and short id. More...
 
template<class T >
constexpr const T & clamp (const T &v, const T &lo, const T &hi)
 Clamps v between lo and hi: lo if v < lo, hi if hi < v, otherwise v More...
 
RemoteStatusTy RemoteGetStatus ()
 Returns the current Remote status. More...
 
void RemoteRecvStart (const RemoteCBFctTy &_rmtCBFcts)
 Starts the listener, will call provided callback functions with received messages. More...
 
void RemoteRecvStop ()
 Stops the receiver. More...
 
void TwoDDrawLabels ()
 Write the labels of all aircraft. More...
 
int CPLabelDrawing (XPLMDrawingPhase, int, void *)
 Drawing callback, called by X-Plane in every drawing cycle. More...
 
void TwoDActivate ()
 Activate actual label drawing, esp. set up drawing callback. More...
 
void TwoDDeactivate ()
 Deactivate actual label drawing, esp. stop drawing callback. More...
 
void TwoDInit ()
 Initialize the module. More...
 
void TwoDCleanup ()
 Grace cleanup. More...
 
void AIMultiClearAIDataRefs (multiDataRefsTy &drM, bool bDeactivateToZero)
 Resets all actual values of the AI/multiplayer dataRefs of one plane to something initial. More...
 
void AIMultiClearInfoDataRefs (infoDataRefsTy &drI)
 Clears the shared info dataRefs. More...
 
bool GoTCASOverride ()
 Are we going to new (TCAS override) or the old way? More...
 
size_t AIUpdateMultiplayerDataRefs ()
 The old way: Update Multiplayer dataRefs directly. More...
 
size_t AIUpdateTCASTargets ()
 The modern way: Use TCAS override and update TCAS targets. More...
 
void AIAssignSlots (size_t fromSlot, size_t toSlot)
 Assigns slots, ie. planes to places in gSlots. More...
 
void AIMultiUpdate ()
 Updates all TCAS target dataRefs, both standard X-Plane, as well as additional shared dataRefs for text publishing. More...
 
int AIMultiControlPlaneCount (XPLMDrawingPhase, int inIsBefore, void *)
 Callback to toggle aircraft count ("TCAS hack") More...
 
void AIMultiClearTcasDataRefs ()
 Clears the key (mode_s) of the TCAS target dataRefs. More...
 
void AIMultiInitAllDataRefs (bool bDeactivateToZero)
 Reset all (controlled) multiplayer dataRef values of all planes. More...
 
void AIMultiInformDREs ()
 Inform DRE and DRT of our shared dataRefs. More...
 
void AIMultiInit ()
 Initialize the module. More...
 
void AIMultiCleanup ()
 Grace cleanup. More...
 
void AcInit ()
 Initialize the module. More...
 
void AcCleanup ()
 Grace cleanup, esp. remove all aircraft. More...
 
std::string CSLModelGetKeyStr (int _related, const std::string &_type, const std::string &_id)
 
std::string CSLModelsConvPackagePath (const std::string &pkgPath, int lnNr, bool bPkgOptional=false)
 Turn a relative package path into a full path. More...
 
void CSLModelsAdd (CSLModel &_csl)
 Adds a readily defined CSL model to all the necessary maps, resets passed-in reference. More...
 
const char * CSLModelsReadPkgId (const std::string &path)
 Scans an xsb_aircraft.txt file for EXPORT_NAME entries to fill the list of packages. More...
 
const char * CSLModelsFindPkgs (const std::string &_path, std::vector< std::string > &paths, int _maxDepth=5)
 Recursively scans folders to find xsb_aircraft.txt files of CSL packages. More...
 
void AcTxtLine_DEPENDENCY (std::vector< std::string > &tokens, int lnNr)
 Process an DEPENDENCY line of an xsb_aircraft.txt file. More...
 
void AcTxtLine_OBJ8_AIRCRAFT (CSLModel &csl, const std::string &ln, const std::string &xsbAircraftPath, const std::string &exportName, int lnNr)
 Process an OBJ8_AIRCRAFT line of an xsb_aircraft.txt file. More...
 
void AcTxtLine_OBJECT_AIRCRAFT (CSLModel &csl, const std::string &, int)
 Process an OBJECT or AIRCRAFT line of an xsb_aircraft.txt file (which are no longer supported) More...
 
void AcTxtLine_OBJ8 (CSLModel &csl, std::vector< std::string > &tokens, int lnNr)
 
void AcTxtLine_VERT_OFFSET (CSLModel &csl, std::vector< std::string > &tokens, int lnNr)
 Process an VERT_OFFSET line of an xsb_aircraft.txt file. More...
 
void AcTxtLine_OFFSET (CSLModel &csl, std::vector< std::string > &tokens, int lnNr)
 
void AcTxtLine_MATCHES (CSLModel &csl, std::vector< std::string > &tokens, int lnNr)
 Process an ICAO, AIRLINE, LIVERY, or MATCHES line of an xsb_aircraft.txt file. More...
 
int StrCntString (const mapStrIntTy &m, std::string &s)
 Compiles a string from a map of string->int like "(A320 x 5, A388 x 12)". More...
 
const char * CSLModelsProcessAcFile (const std::string &path)
 Process one xsb_aircraft.txt file for importing OBJ8 models. More...
 
void CSLModelsInit ()
 Initialization. More...
 
void CSLModelsCleanup ()
 Grace cleanup. More...
 
const char * CSLModelsLoad (const std::string &_path, int _maxDepth=5)
 Read the CSL Models found in the given path and below. More...
 
CSLModelCSLModelById (const std::string &_cslId, mapCSLModelTy::iterator *_pOutIter=nullptr)
 Find a model by unique id. More...
 
CSLModelCSLModelByKey (const std::string &_cslKey, mapCSLModelTy::iterator *_pOutIter=nullptr)
 Find a model by (even more) unique key. More...
 
template<class IteratorT >
IteratorT iterRnd (IteratorT lower, IteratorT upper)
 Returns any random value in the range [cslLower; cslUpper), or upper if there is no value in that range. More...
 
bool CSLFindMatch (const std::string &_type, const std::string &_airline, const std::string &_livery, bool bIgnoreNoMatch, int &quality, CSLModel *&pModel)
 Tries finding a match using both aircraft and Doc8643 attributes. More...
 
int CSLModelMatching (const std::string &_type, const std::string &_airline, const std::string &_livery, CSLModel *&pModel)
 Find a matching model. More...
 
bool IsInRect (float x, float y, const float bounds_ltrb[4])
 Tests if x/y lies within the rect, given as a float[4] array. More...
 
void MapPrepareCacheCB (XPLMMapLayerID, const float *inTotalMapBoundsLeftTopRightBottom, XPLMMapProjectionID projection, void *)
 Prepare map drawing information. More...
 
void MapIconDrawingCB (XPLMMapLayerID inLayer, const float *inMapBoundsLeftTopRightBottom, float, float mapUnitsPerUserInterfaceUnit, XPLMMapStyle, XPLMMapProjectionID projection, void *refcon)
 Actually draw the icons into the map. More...
 
void MapLabelDrawingCB (XPLMMapLayerID inLayer, const float *inMapBoundsLeftTopRightBottom, float, float mapUnitsPerUserInterfaceUnit, XPLMMapStyle, XPLMMapProjectionID projection, void *refcon)
 Actually draw the labels into th emap. More...
 
void MapDeleteCB (XPLMMapLayerID inLayer, void *)
 Called when a map is about to be deleted. More...
 
void MapLayerCreate (const char *mapIdentifier)
 Create our map layer for the given map. More...
 
void MapCreateAll ()
 Loop all existing maps and create our map layer for them. More...
 
void MapDestroyAll ()
 Remove all our map layers. More...
 
void MapCreateCB (const char *mapIdentifier, void *)
 Callback called when a map is created. We then need to add our layer to it. More...
 
void MapInit ()
 Initialize the module. More...
 
void MapCleanup ()
 Grace cleanup. More...
 
const std::vector< InetAddrTy > & NetwGetLocalAddresses ()
 Return all local addresses (also cached locally) More...
 
bool NetwIsLocalAddr (const InetAddrTy &addr)
 Is given address a local one? More...
 
bool NetwIsLocalAddr (const sockaddr *sa)
 Is given address a local one? More...
 
const char * RelatedLoad (const std::string &_path)
 Read the related.txt file, full path passed in. More...
 
int RelatedGet (const std::string &_acType)
 Find the related group for an ICAO a/c type, 0 if none. More...
 
const char * Doc8643Load (const std::string &_path)
 Load the content of the provided Doc8643.txt file. More...
 
const Doc8643Doc8643Get (const std::string &_type)
 Return a reference to the matching Doc8643 object. More...
 
bool Doc8643IsTypeValid (const std::string &_type)
 Is the given aircraft type a valid ICAO type as per Doc8643? More...
 
const char * Obj8DataRefsLoad (const std::string &_path)
 Load the content of the provided Obj8DataRefs.txt file. More...
 
std::unique_lock< std::mutex > glockRmtData (gmutexRmtData)
 The lock that we keep during handling of the flight loop. More...
 
bool RmtSendContinue ()
 Conditions for continued send operation. More...
 
void RmtSendProcessQueue ()
 Process the data passed down to us in the queue. More...
 
void RmtSendSettings ()
 Send our settings. More...
 
void RmtSendLoop ()
 Sending function, ie. we are actively sending data out. More...
 
void RmtSendMain ()
 Thread main function for the sender. More...
 
void RmtSendBeacon ()
 Sends an Interest Beacon. More...
 
bool RmtRecvContinue ()
 Conditions for continued receive operation. More...
 
void RmtRecvMain ()
 Thread main function for the receiver. More...
 
void RmtStartMCThread (bool bSender)
 Start the background thread to listen to multicast, to see if anybody is interested in our data. More...
 
void RmtStopAll ()
 Stop all threads and communication with the network. More...
 
void RemoteInit ()
 Initialize the module. More...
 
void RemoteCleanup ()
 Grace cleanup, stops all threads. More...
 
void RemoteSenderUpdateStatus ()
 Compares current vs. expected status and takes appropriate action. More...
 
void RemoteAcEnqueueStarts (float now)
 
void RemoteAcEnqueue (const Aircraft &ac)
 Regularly called from the flight loop callback to send a/c date onto the network. More...
 
void RemoteAcEnqueueDone ()
 Informs us that all a/c have been processed: All pending messages to be sent now. More...
 
void RemoteAcRemove (const Aircraft &ac)
 Informs us about an aircraft deletion. More...
 
void RemoteAcClearAll ()
 Informs us that there are no more aircraft, clear our caches! More...
 
int PrefsFuncIntDefault (const char *, const char *, int _default)
 Default config function just always returns the provided default value. More...
 
bool ExistsFile (const std::string &filename)
 Does a file path exist? More...
 
bool IsDir (const std::string &path)
 Is path a directory? More...
 
bool CreateDir (const std::string &path)
 Create directory if it does not exist. More...
 
bool CopyFileIfNewer (const std::string &source, const std::string &destDir)
 Copy file if source is newer or destination missing. More...
 
std::list< std::string > GetDirContents (const std::string &path)
 List of files in a directory (wrapper around XPLMGetDirectoryContents) More...
 
std::istream & safeGetline (std::istream &is, std::string &t)
 Read a line from a text file, no matter if ending on CRLF or LF. More...
 
const std::string & GetXPSystemPath ()
 Returns XP's system directory, including a trailing slash. More...
 
std::string StripXPSysDir (const std::string &path)
 If a path starts with X-Plane's system directory it is stripped. More...
 
void RemoveExtension (std::string &path)
 Removes everything after the last dot, the dot including. More...
 
std::string & str_tolower (std::string &s)
 change a std::string to uppercase More...
 
std::vector< std::string > str_tokenize (const std::string s, const std::string tokens, bool bSkipEmpty=true)
 separates string into tokens More...
 
float headDiff (float head1, float head2)
 (Shortest) difference between 2 angles: How much to turn to go from h1 to h2? More...
 
float GetMiscNetwTime ()
 Get synched network time from X-Plane (sim/network/misc/network_time_sec) as used in Log.txt. More...
 
std::string GetMiscNetwTimeStr (float _time=NAN)
 Return the network time as a string like used in the XP's Log.txt. More...
 
const char * GetGraphicsDriverTxt ()
 Text string for current graphics driver in use. More...
 
bool CheckEverySoOften (float &_lastCheck, float _interval, float _now)
 Convenience function to check on something at most every x seconds. More...
 
const char * LogGetString (const char *szFile, int ln, const char *szFunc, logLevelTy lvl, const char *szMsg, va_list args)
 Returns ptr to static buffer filled with formatted log string. More...
 
void LogMsg (const char *szFile, int ln, const char *szFunc, logLevelTy lvl, const char *szMsg,...) XPMP2_FMTARGS(5)
 Log Text to log file. More...
 
float PrefsFuncFloatDefault (const char *, const char *, float _default)
 
std::string & rtrim (std::string &s, const char *t=WHITESPACE)
 trimming of string (from right) More...
 
std::string & ltrim (std::string &s, const char *t=WHITESPACE)
 trimming of string (from left) More...
 
std::string & trim (std::string &s, const char *t=WHITESPACE)
 trimming of string (from both ends) More...
 
template<class T >
rad2deg (const T _rad)
 Convert radians to degrees, normalized to [0..360) More...
 
template<class T >
deg2rad (const T _deg)
 Convert degree to radians. More...
 
template<class T >
sqr (const T a)
 Square. More...
 
template<class T >
dist (const T x1, const T y1, const T z1, const T x2, const T y2, const T z2)
 Pythagorean distance between two points in a 3-D world. More...
 
float atan2deg (float x, float y)
 atan2 converted to degrees: the angle between (0|0) and the given point More...
 
float angleLocCoord (float x1, float z1, float x2, float z2)
 Angle of line from point (x1|z1) to point (x2|z2) More...
 
template<class numT >
numT headNormalize (numT _head)
 Normalize a heading value to [0..360), works for both float and double values. More...
 
bool CheckEverySoOften (float &_lastCheck, float _interval)
 Convenience function to check on something at most every x seconds. More...
 
std::string TOPOSIX (const std::string &p)
 On Lin/Win there is no need for a conversion, but we do treat p now as std::string More...
 
std::string FROMPOSIX (const std::string &p)
 On Lin/Win there is no need for a conversion, but we do treat p now as std::string More...
 
void XPMPSendNotification (const Aircraft &plane, XPMPPlaneNotification _notification)
 Send a notification to all observers. More...
 
const char * XPMPValidateResourceFiles (const char *resourceDir)
 Validate all required files are available in the resource directory. More...
 

Variables

constexpr float RPM_to_RADs = 0.10471975511966f
 Convert revolutions-per-minute (RPM) to radians per second (rad/s) by multiplying with PI/30. More...
 
constexpr double M_per_FT = 0.3048
 Convert feet to meters, e.g. for altitude calculations. More...
 
constexpr int M_per_NM = 1852
 Convert nautical miles to meters. More...
 
constexpr const char * REMOTE_SIGNATURE = "TwinFan.plugin.XPMP2.Remote"
 The signature of the XPMP2 Remote Client. More...
 
const std::array< RemoteDataRefPackTy, V_COUNTREMOTE_DR_DEF
 An array holding all dataRef packing definitions. More...
 
struct XPMP2::RemoteMsgBaseTy PACKED
 
constexpr std::uint8_t RMT_VER_BEACON = 0
 Interest Beacon message version number. More...
 
constexpr int REMOTE_SEND_SETTINGS_INTVL = 20
 How often to send settings? [s]. More...
 
constexpr std::uint8_t RMT_VER_SETTINGS = 0
 Setttings message version number. More...
 
constexpr std::uint8_t RMT_VER_AC_DETAIL = 1
 A/C detail message version number. More...
 
constexpr std::uint8_t RMT_VER_AC_POS_UPDATE = 0
 A/C Position update message version number. More...
 
constexpr double REMOTE_DEGREE_RES = 0.00000001
 What is the maximum difference a RemoteAcPosUpdateTy can hold? More...
 
constexpr double REMOTE_MAX_DIFF_DEGREE = REMOTE_DEGREE_RES * INT16_MAX
 maximum degree difference that can be represented in a pos update msg More...
 
constexpr double REMOTE_ALT_FT_RES = 0.01
 resolution of altitude[ft] updates More...
 
constexpr double REMOTE_MAX_DIFF_ALT_FT = REMOTE_ALT_FT_RES * INT16_MAX
 maximum altitude[ft] difference that can be represented in a pos update msg More...
 
constexpr float REMOTE_TIME_RES = 0.0001f
 resolution of time difference More...
 
constexpr float REMOTE_MAX_DIFF_TIME = REMOTE_TIME_RES * UINT16_MAX
 maximum time difference thatn can be represented in a pos update msg More...
 
constexpr std::uint8_t RMT_VER_AC_ANIM = 0
 A/C Position update message version number. More...
 
constexpr std::uint8_t RMT_VER_AC_REMOVE = 0
 A/C removal message version number. More...
 
constexpr float FAR_AWAY_VAL_GL = 9999999.9f
 Don't dare using NAN...but with this coordinate for x/y/z a plane should be far out and virtually invisible. More...
 
constexpr float AISLOT_CHANGE_PERIOD = 15.0f
 How often do we reassign AI slots? [seconds]. More...
 
constexpr int AI_PRIO_MULTIPLIER = 10 * M_per_NM
 How much distance does each AIPrio add? More...
 
float F_NULL [10] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}
 A constant array of zero values supporting quick array initialization. More...
 
constexpr int XPLM_PHASE_AIRPLANES = 25
 The drawing phase "xplm_Phase_Airplanes" is deprecated in XP11.50 upwards, but we need it in earlier versions to fake TCAS. More...
 
const char * DATA_REF_EDITORS []
 
std::vector< std::string > vecDREdataRefStr
 list of dataRef strings to be send to the editors More...
 
constexpr size_t SDR_CSLMODEL_TXT_SIZE = 40
 Number of characters to be allowed for CSL model text. More...
 
XPLMFlightLoopID gFlightLoopID = nullptr
 The id of our flight loop callback. More...
 
std::vector< std::unique_ptr< std::string > > drStrings
 
std::vector< XPLMDataRef > ahDataRefs
 Registered dataRefs. More...
 
XPLMFlightLoopID gGarbageCollectionID = nullptr
 The ids of our garbage collection flight loop callback. More...
 
constexpr float GARBAGE_COLLECTION_PERIOD = 60.0f
 How often to call the garbage collection [s]. More...
 
constexpr float GARBAGE_COLLECTION_TIMEOUT = 180.0f
 Unload an unused object after how many seconds? More...
 
constexpr int MAP_ICON_WIDTH = 3
 Dimenson of MapIcon.png. More...
 
constexpr int MAP_ICON_HEIGHT = 3
 Dimenson of MapIcon.png. More...
 
constexpr int MAP_MIN_ICON_SIZE = 40
 Minimum icon size in map in UI units. More...
 
constexpr float MAP_AC_SIZE = 30.0f
 Assumed size of an aircraft in m. More...
 
std::array< const char *, 2 > ALL_MAPS
 The list of known maps, which are hard-coded by X-Plane's SDK. More...
 
constexpr int SERR_LEN = 100
 Maximum length of OS error message. More...
 
std::recursive_mutex mtxSocketClose
 Mutex to ensure closing is done in one thread only to avoid race conditions on deleting the buffer. More...
 
std::vector< InetAddrTygaddrLocal
 List of local IP addresses. More...
 
constexpr SOCKET INVALID_SOCKET = -1
 
constexpr int ERR_CFG_FILE_MAXWARN = 5
 Maximum number of warnings during file read before bailing. More...
 
const Doc8643 DOC8643_EMPTY
 
constexpr int REMOTE_RECV_BEACON_INTVL = 15
 How often to send an Interest Beacon? [s]. More...
 
constexpr float REMOTE_SEND_AC_DETAILS_INTVL = 10.f
 How often to send full a/c details? [s]. More...
 
mapRmtAcCacheTy gmapRmtAcCache
 Cache for last data sent out to the network. More...
 
unsigned gFullUpdDue = 0
 What's the full update group that has its turn now? More...
 
unsigned gFullUpdLastDone = 0
 the last actually processed full update group More...
 
unsigned gNxtFullUpdGrpToAssign = 0
 What's the next group number to assign to the next a/c? (Assigned will be the value incremented by 1) More...
 
float gNow = 0.0f
 Current network timestamp. More...
 
float gNxtTxfTime = 0.0f
 When to actually process position updates next? More...
 
queueRmtDataTy gqueueRmtData
 the queue for passing data from main to network thread More...
 
std::condition_variable gcvRmtData
 notifies the network thread of available data to be processed More...
 
std::mutex gmutexRmtData
 
constexpr int MC_MAX_ERR =5
 after this many errors we no longer try listening More...
 
std::thread gThrMC
 remote listening/sending thread More...
 
UDPMulticastgpMc = nullptr
 multicast socket for listening/sending (destructor uses locks, which don't work during module shutdown, so can't create a global object due to its exit-time destructor) More...
 
volatile bool gbStopMCThread = false
 Shall the network thread stop? More...
 
int gCntMCErr = 0
 error counter for network thread More...
 
float gSendSettingsLast = 0.0f
 Timestamp when we sent our settings the last time. More...
 
RmtMsgBufTy< RemoteAcDetailTy, RMT_MSG_AC_DETAILED, RMT_VER_AC_DETAILgMsgAcDetail
 A/C Detail message. More...
 
RmtMsgBufTy< RemoteAcPosUpdateTy, RMT_MSG_AC_POS_UPDATE, RMT_VER_AC_POS_UPDATEgMsgAcPosUpdate
 A/C Position Update message. More...
 
RmtMsgBufTy< RemoteAcAnimTy, RMT_MSG_AC_ANIM, RMT_VER_AC_ANIMgMsgAcAnim
 A/C Animation dataRefs message. More...
 
RmtMsgBufTy< RemoteAcRemoveTy, RMT_MSG_AC_REMOVE, RMT_VER_AC_REMOVEgMsgAcRemove
 A/C Removal message. More...
 
RemoteCBFctTy gRmtCBFcts
 The callback function pointers the remote client plugin provided. More...
 
GlobVars glob
 The one and only global variable structure. More...
 
const char * LOG_LEVEL []
 
constexpr const char * RSRC_RELATED = "related.txt"
 
constexpr const char * RSRC_DOC8643 = "Doc8643.txt"
 
constexpr const char * RSRC_MAP_ICONS = "MapIcons.png"
 
constexpr const char * RSRC_OBJ8DATAREFS = "Obj8DataRefs.txt"
 
constexpr double PI = 3.1415926535897932384626433832795028841971693993751
 Pi. More...
 
constexpr float XPMP2_VER = 2.30f
 XPMP2 version number. More...
 

Class Documentation

◆ XPMP2::TcasLightsTy

union XPMP2::TcasLightsTy

A structure simplifying communicaton with sim/cockpit2/tcas/targets/position/lights.

Class Members
struct BitsTy b
int i the full integer value

◆ XPMP2::RmtDataAcAnimTy.__unnamed4__

union XPMP2::RmtDataAcAnimTy.__unnamed4__
Class Members
char bufSize[RemoteAcAnimTy::msgSize(V_COUNT)] a declaration that only makes sure that enough memory is reserved so that XPMP2::RmtDataAcAnimTy::data::v can fill up to max
RemoteAcAnimTy data The animation dataRef values element.

Typedef Documentation

◆ listCSLObjTy

typedef std::list<CSLObj> XPMP2::listCSLObjTy

List of objects.

◆ listObj8DataRefsTy

a list of Obj8DataRefs definitions

◆ listXPMPPlaneNotifierTy

◆ mapAcByDistTy

typedef std::map<float,XPMPPlaneID> XPMP2::mapAcByDistTy

Map of Aircrafts, sorted by (priority-biased) distance.

◆ mapAcTy

typedef std::map<XPMPPlaneID,Aircraft*> XPMP2::mapAcTy

Map of all aircraft, key is tthe plane id.

Note
Map stores pointers and does not own the objects. Plugin (the one using this library) is expected to own and destroy the object

◆ mapCSLModelTy

typedef std::map<std::string,CSLModel> XPMP2::mapCSLModelTy

Map of CSLModels (owning the object), ordered by related group / type.

◆ mapCSLPackageTy

typedef std::map<std::string,std::string> XPMP2::mapCSLPackageTy

Map of CSLPackages: Maps an id to the base path (path ends on forward slash)

◆ mapDoc8643Ty

typedef std::map<std::string, Doc8643> XPMP2::mapDoc8643Ty

Map of Doc8643 information, key is the (icao) type code.

◆ mapMapLayerIDTy

typedef std::map<std::string, XPLMMapLayerID> XPMP2::mapMapLayerIDTy

A map holding our layer identifier, indexed by the map's name.

◆ mapRelatedTy

typedef std::map<std::string, int> XPMP2::mapRelatedTy

Map of group membership: ICAO a/c type maps to line in related.txt.

◆ mapRmtAcCacheTy

Defines a map with the plane id as key and the aboce cache structure as payload.

◆ mapStrIntTy

typedef std::map<std::string, int> XPMP2::mapStrIntTy

a map of a text and a counter

◆ mmapCSLModelPTy

typedef std::multimap<unsigned long,std::pair<CSLModel*,const CSLModel::MatchCritTy*> > XPMP2::mmapCSLModelPTy

Multimap of references to CSLModels and match criteria for matching purposes.

◆ pairOfStrTy

typedef std::pair<std::string,std::string> XPMP2::pairOfStrTy

◆ ptrRmtDataAcAnimTy

typedef std::unique_ptr<RmtDataAcAnimTy> XPMP2::ptrRmtDataAcAnimTy

Smart pointer to XPMP2::RmtDataAcAnimTy.

◆ ptrRmtDataBaseTy

typedef std::unique_ptr<RmtDataBaseTy> XPMP2::ptrRmtDataBaseTy

Smart pointer to XPMP2::RmtDataBaseTy by which we manage objects of this and derived types.

◆ queueRmtDataTy

typedef std::queue<ptrRmtDataBaseTy,std::list<ptrRmtDataBaseTy> > XPMP2::queueRmtDataTy

A queue managing the information objects, used to transfer data between main thread and network thread.

◆ RmtDataAcDetailTy

A/C Detail queue type.

◆ RmtDataAcPosUpdateTy

A/C Position Update queue type.

◆ RmtDataAcRemoveTy

A/C Removal queue type.

◆ SOCKET

typedef int XPMP2::SOCKET

Windows defines SOCKET, so we define it for non-Windows manually.

Enumeration Type Documentation

◆ DR_VALS

enum XPMP2::DR_VALS : std::uint8_t

The dataRefs provided by XPMP2 to the CSL models.

Enumerator
V_CONTROLS_GEAR_RATIO 

libxplanemp/controls/gear_ratio and
sim/cockpit2/tcas/targets/position/gear_deploy

V_CONTROLS_NWS_RATIO 

libxplanemp/controls/nws_ratio, the nose wheel angle, actually in degrees

V_CONTROLS_FLAP_RATIO 

libxplanemp/controls/flap_ratio and
sim/cockpit2/tcas/targets/position/flap_ratio and ...flap_ratio2

V_CONTROLS_SPOILER_RATIO 

libxplanemp/controls/spoiler_ratio

V_CONTROLS_SPEED_BRAKE_RATIO 

libxplanemp/controls/speed_brake_ratio and
sim/cockpit2/tcas/targets/position/speedbrake_ratio

V_CONTROLS_SLAT_RATIO 

libxplanemp/controls/slat_ratio and
sim/cockpit2/tcas/targets/position/slat_ratio

V_CONTROLS_WING_SWEEP_RATIO 

libxplanemp/controls/wing_sweep_ratio and
sim/cockpit2/tcas/targets/position/wing_sweep

V_CONTROLS_THRUST_RATIO 

libxplanemp/controls/thrust_ratio and
sim/cockpit2/tcas/targets/position/throttle

V_CONTROLS_YOKE_PITCH_RATIO 

libxplanemp/controls/yoke_pitch_ratio and
sim/cockpit2/tcas/targets/position/yolk_pitch

V_CONTROLS_YOKE_HEADING_RATIO 

libxplanemp/controls/yoke_heading_ratio and
sim/cockpit2/tcas/targets/position/yolk_yaw

V_CONTROLS_YOKE_ROLL_RATIO 

libxplanemp/controls/yoke_roll_ratio and
sim/cockpit2/tcas/targets/position/yolk_roll

V_CONTROLS_THRUST_REVERS 

libxplanemp/controls/thrust_revers

V_CONTROLS_TAXI_LITES_ON 

libxplanemp/controls/taxi_lites_on and
sim/cockpit2/tcas/targets/position/lights

V_CONTROLS_LANDING_LITES_ON 

libxplanemp/controls/landing_lites_on and
sim/cockpit2/tcas/targets/position/lights

V_CONTROLS_BEACON_LITES_ON 

libxplanemp/controls/beacon_lites_on and
sim/cockpit2/tcas/targets/position/lights

V_CONTROLS_STROBE_LITES_ON 

libxplanemp/controls/strobe_lites_on and
sim/cockpit2/tcas/targets/position/lights

V_CONTROLS_NAV_LITES_ON 

libxplanemp/controls/nav_lites_on and
sim/cockpit2/tcas/targets/position/lights

V_GEAR_NOSE_GEAR_DEFLECTION_MTR 

libxplanemp/gear/nose_gear_deflection_mtr

V_GEAR_TIRE_VERTICAL_DEFLECTION_MTR 

libxplanemp/gear/tire_vertical_deflection_mtr

V_GEAR_TIRE_ROTATION_ANGLE_DEG 

libxplanemp/gear/tire_rotation_angle_deg

V_GEAR_TIRE_ROTATION_SPEED_RPM 

libxplanemp/gear/tire_rotation_speed_rpm

V_GEAR_TIRE_ROTATION_SPEED_RAD_SEC 

libxplanemp/gear/tire_rotation_speed_rad_sec

V_ENGINES_ENGINE_ROTATION_ANGLE_DEG 

libxplanemp/engines/engine_rotation_angle_deg

V_ENGINES_ENGINE_ROTATION_SPEED_RPM 

libxplanemp/engines/engine_rotation_speed_rpm

V_ENGINES_ENGINE_ROTATION_SPEED_RAD_SEC 

libxplanemp/engines/engine_rotation_speed_rad_sec

V_ENGINES_PROP_ROTATION_ANGLE_DEG 

libxplanemp/engines/prop_rotation_angle_deg

V_ENGINES_PROP_ROTATION_SPEED_RPM 

libxplanemp/engines/prop_rotation_speed_rpm

V_ENGINES_PROP_ROTATION_SPEED_RAD_SEC 

libxplanemp/engines/prop_rotation_speed_rad_sec

V_ENGINES_THRUST_REVERSER_DEPLOY_RATIO 

libxplanemp/engines/thrust_reverser_deploy_ratio

V_ENGINES_ENGINE_ROTATION_ANGLE_DEG1 

libxplanemp/engines/engine_rotation_angle_deg1

V_ENGINES_ENGINE_ROTATION_ANGLE_DEG2 

libxplanemp/engines/engine_rotation_angle_deg2

V_ENGINES_ENGINE_ROTATION_ANGLE_DEG3 

libxplanemp/engines/engine_rotation_angle_deg3

V_ENGINES_ENGINE_ROTATION_ANGLE_DEG4 

libxplanemp/engines/engine_rotation_angle_deg4

V_ENGINES_ENGINE_ROTATION_SPEED_RPM1 

libxplanemp/engines/engine_rotation_speed_rpm1

V_ENGINES_ENGINE_ROTATION_SPEED_RPM2 

libxplanemp/engines/engine_rotation_speed_rpm2

V_ENGINES_ENGINE_ROTATION_SPEED_RPM3 

libxplanemp/engines/engine_rotation_speed_rpm3

V_ENGINES_ENGINE_ROTATION_SPEED_RPM4 

libxplanemp/engines/engine_rotation_speed_rpm4

V_ENGINES_ENGINE_ROTATION_SPEED_RAD_SEC1 

libxplanemp/engines/engine_rotation_speed_rad_sec1

V_ENGINES_ENGINE_ROTATION_SPEED_RAD_SEC2 

libxplanemp/engines/engine_rotation_speed_rad_sec2

V_ENGINES_ENGINE_ROTATION_SPEED_RAD_SEC3 

libxplanemp/engines/engine_rotation_speed_rad_sec3

V_ENGINES_ENGINE_ROTATION_SPEED_RAD_SEC4 

libxplanemp/engines/engine_rotation_speed_rad_sec4

V_MISC_TOUCH_DOWN 

libxplanemp/misc/touch_down

V_COUNT 

always last, number of dataRefs XPMP2 pre-defines

◆ logLevelTy

Logging level.

Enumerator
logDEBUG 

Debug, highest level of detail.

logINFO 

regular info messages

logWARN 

warnings, i.e. unexpected, but uncritical events, maybe leading to unwanted display, but still: display of aircraft

logERR 

errors mean, aircraft can potentially not be displayed

logFATAL 

fatal is shortly before a crash

logMSG 

will always be output, no matter what has been configured, cannot be suppressed

◆ ObjLoadStateTy

State of the X-Plane object: Is it being loaded or available?

Enumerator
OLS_INVALID 

loading once failed -> invalid!

OLS_UNAVAIL 

Not yet tried loading the CSL object.

OLS_COPYING 

creating a new .obj file copy, replacing dataRefs and textures

OLS_LOADING 

async load underway

OLS_AVAILABLE 

X-Plane object available in xpObj

◆ RemoteCfgTy

enum XPMP2::RemoteCfgTy : int

Configuration for remote communications support.

Enumerator
REMOTE_CFG_OFF 

config: force off

REMOTE_CFG_AUTO 

config: on if in a netwoked/multiplayer setup

REMOTE_CFG_ON 

config: force on

◆ RemoteMsgTy

enum XPMP2::RemoteMsgTy : std::uint8_t

Message type.

Enumerator
RMT_MSG_INTEREST_BEACON 

beacon sent by a remote client to signal interest in data

RMT_MSG_SEND 

internal indicator telling to send out all pending messages

RMT_MSG_SETTINGS 

a sender's id and its settings

RMT_MSG_AC_DETAILED 

aircraft full details, needed to create new a/c objects and to re-synch all remote data

RMT_MSG_AC_POS_UPDATE 

aircraft differences only

RMT_MSG_AC_ANIM 

aircraft animation values (dataRef values) only

RMT_MSG_AC_REMOVE 

aircraft is removed

◆ RemoteStatusTy

enum XPMP2::RemoteStatusTy : unsigned

State of remote communcations.

Enumerator
REMOTE_OFF 

no remote connectivtiy, not listening, not sending

REMOTE_SEND_WAITING 

listening for a request to send data, but not actively sending data

REMOTE_SENDING 

actively sending aircraft data out to the network

REMOTE_RECV_WAITING 

waiting to receive data, periodically sending a token of interest

REMOTE_RECEIVING 

actively receiving data

Function Documentation

◆ AcCleanup()

void XPMP2::AcCleanup ( )

Grace cleanup, esp. remove all aircraft.

◆ AcFindByID()

Aircraft * XPMP2::AcFindByID ( XPMPPlaneID  _id)

Find aircraft by its plane ID, can return nullptr.

◆ AcInit()

void XPMP2::AcInit ( )

Initialize the module.

◆ AcTxtLine_DEPENDENCY()

void XPMP2::AcTxtLine_DEPENDENCY ( std::vector< std::string > &  tokens,
int  lnNr 
)

Process an DEPENDENCY line of an xsb_aircraft.txt file.

◆ AcTxtLine_MATCHES()

void XPMP2::AcTxtLine_MATCHES ( CSLModel csl,
std::vector< std::string > &  tokens,
int  lnNr 
)

Process an ICAO, AIRLINE, LIVERY, or MATCHES line of an xsb_aircraft.txt file.

◆ AcTxtLine_OBJ8()

void XPMP2::AcTxtLine_OBJ8 ( CSLModel csl,
std::vector< std::string > &  tokens,
int  lnNr 
)

Process an OBJ8 line of an xsb_aircraft.txt file We don't care what type of object it is (ignoring the 1st parameter)

◆ AcTxtLine_OBJ8_AIRCRAFT()

void XPMP2::AcTxtLine_OBJ8_AIRCRAFT ( CSLModel csl,
const std::string &  ln,
const std::string &  xsbAircraftPath,
const std::string &  exportName,
int  lnNr 
)

Process an OBJ8_AIRCRAFT line of an xsb_aircraft.txt file.

◆ AcTxtLine_OBJECT_AIRCRAFT()

void XPMP2::AcTxtLine_OBJECT_AIRCRAFT ( CSLModel csl,
const std::string &  ,
int   
)

Process an OBJECT or AIRCRAFT line of an xsb_aircraft.txt file (which are no longer supported)

◆ AcTxtLine_OFFSET()

void XPMP2::AcTxtLine_OFFSET ( CSLModel csl,
std::vector< std::string > &  tokens,
int  lnNr 
)

Process an OFFSET line of a PilotEdge xsb_aircraft.txt file, actually its 3rd parameter only (we still don't know what the first 2 are)

See also
http://forums.pilotedge.net/viewtopic.php?f=12&t=7236#p47925

◆ AcTxtLine_VERT_OFFSET()

void XPMP2::AcTxtLine_VERT_OFFSET ( CSLModel csl,
std::vector< std::string > &  tokens,
int  lnNr 
)

Process an VERT_OFFSET line of an xsb_aircraft.txt file.

◆ AIAssignSlots()

void XPMP2::AIAssignSlots ( size_t  fromSlot,
size_t  toSlot 
)

Assigns slots, ie. planes to places in gSlots.

Called in several passes as to make sure that the lowest n slots are occupied by the closest n planes.

◆ AIMultiCleanup()

void XPMP2::AIMultiCleanup ( )

Grace cleanup.

Make sure we aren't in control, then Unshare the shared dataRefs

◆ AIMultiClearAIDataRefs()

void XPMP2::AIMultiClearAIDataRefs ( multiDataRefsTy mdr,
bool  bDeactivateToZero = false 
)

Resets all actual values of the AI/multiplayer dataRefs of one plane to something initial.

◆ AIMultiClearInfoDataRefs()

void XPMP2::AIMultiClearInfoDataRefs ( infoDataRefsTy drI)

Clears the shared info dataRefs.

◆ AIMultiClearTcasDataRefs()

void XPMP2::AIMultiClearTcasDataRefs ( )

Clears the key (mode_s) of the TCAS target dataRefs.

◆ AIMultiControlPlaneCount()

int XPMP2::AIMultiControlPlaneCount ( XPLMDrawingPhase  ,
int  inIsBefore,
void *   
)

Callback to toggle aircraft count ("TCAS hack")

We use AI Aircraft to simulate TCAS blibs, but we don't want these AI Aircraft to actually draw. So during aircraft drawing phase we tell X-Plane there are no AI planes, afterwards we put the correct number back

Note
Only used if TCAS fallback via classic multiplayer dataRefs is active

◆ AIMultiInformDREs()

void XPMP2::AIMultiInformDREs ( )

Inform DRE and DRT of our shared dataRefs.

◆ AIMultiInit()

void XPMP2::AIMultiInit ( )

Initialize the module.

Fetches all dataRef handles for all dataRefs of all up to 19 AI/multiplayer slots

◆ AIMultiInitAllDataRefs()

void XPMP2::AIMultiInitAllDataRefs ( bool  bDeactivateToZero)

Reset all (controlled) multiplayer dataRef values of all planes.

◆ AIMultiUpdate()

void XPMP2::AIMultiUpdate ( )

Updates all TCAS target dataRefs, both standard X-Plane, as well as additional shared dataRefs for text publishing.

◆ AIUpdateMultiplayerDataRefs()

size_t XPMP2::AIUpdateMultiplayerDataRefs ( )

The old way: Update Multiplayer dataRefs directly.

Returns
Number of TCAS targets produced

◆ AIUpdateTCASTargets()

size_t XPMP2::AIUpdateTCASTargets ( )

The modern way: Use TCAS override and update TCAS targets.

Returns
Number of TCAS targets produced (incl. user's plane)

◆ angleLocCoord()

float XPMP2::angleLocCoord ( float  x1,
float  z1,
float  x2,
float  z2 
)
inline

Angle of line from point (x1|z1) to point (x2|z2)

Note
Points are given in XP's local coordinates with x -> east and z -> south(!), but as in atan2 angles grow counter-clockwise, but we expect clockwise, these 2 effects (z south, counter-clockwise angles) neutralize.
atan2 returns 0° when pointing along the x axis, ie. east, when we would expect a result of 90°. Hence, we need to add 90°=PI/2 to the result.

◆ atan2deg()

float XPMP2::atan2deg ( float  x,
float  y 
)
inline

atan2 converted to degrees: the angle between (0|0) and the given point

◆ CheckEverySoOften() [1/2]

bool XPMP2::CheckEverySoOften ( float &  _lastCheck,
float  _interval 
)
inline

Convenience function to check on something at most every x seconds.

Parameters
_lastCheckProvide a float which holds the time of last check (init with 0.0f)
_interval[seconds] How often to perform the check?
Returns
true if more than _interval time has passed since _lastCheck

◆ CheckEverySoOften() [2/2]

bool XPMP2::CheckEverySoOften ( float &  _lastCheck,
float  _interval,
float  _now 
)

Convenience function to check on something at most every x seconds.

Parameters
_lastCheckProvide a float which holds the time of last check (init with 0.0f)
_interval[seconds] How often to perform the check?
_nowCurrent time, possibly from a call to GetTotalRunningTime()
Returns
true if more than _interval time has passed since _lastCheck

◆ clamp()

template<class T >
constexpr const T& XPMP2::clamp ( const T &  v,
const T &  lo,
const T &  hi 
)
constexpr

Clamps v between lo and hi: lo if v < lo, hi if hi < v, otherwise v

See also
C++17, https://en.cppreference.com/w/cpp/algorithm/clamp
Note
Reimplemented here because Docker clang environment doesn't include it

◆ CopyFileIfNewer()

bool XPMP2::CopyFileIfNewer ( const std::string &  source,
const std::string &  destDir 
)

Copy file if source is newer or destination missing.

Returns
Does the destination file (now) exist?

◆ CPLabelDrawing()

int XPMP2::CPLabelDrawing ( XPLMDrawingPhase  ,
int  ,
void *   
)

Drawing callback, called by X-Plane in every drawing cycle.

◆ CreateDir()

bool XPMP2::CreateDir ( const std::string &  path)

Create directory if it does not exist.

Returns
Does directory (now) exist?

◆ CSLFindMatch()

bool XPMP2::CSLFindMatch ( const std::string &  _type,
const std::string &  _airline,
const std::string &  _livery,
bool  bIgnoreNoMatch,
int &  quality,
CSLModel *&  pModel 
)

Tries finding a match using both aircraft and Doc8643 attributes.

Each attribute is represented by a bit in a bit mask. Lower priority attributes are represented by low value bits, and vice versa high prio match criteria by high value bits. The bit is 0 if the attribute matches and 1 if not. The resulting numeric value of the bitmask is considered the match quality: The lower the number the better the quality.

◆ CSLModelById()

CSLModel * XPMP2::CSLModelById ( const std::string &  _cslId,
mapCSLModelTy::iterator *  _pOutIter = nullptr 
)

Find a model by unique id.

Parameters
_cslIdThe model's unique id to search for (package name/short id)
[out]_pOutIterOptional pointer to an iterator variable, receiving the iterator position of the found model

◆ CSLModelByKey()

CSLModel * XPMP2::CSLModelByKey ( const std::string &  _cslKey,
mapCSLModelTy::iterator *  _pOutIter = nullptr 
)

Find a model by (even more) unique key.

Parameters
_cslKeyThe model's unique key into the map
[out]_pOutIterOptional pointer to an iterator variable, receiving the iterator position of the found model

◆ CSLModelByPkgShortId()

CSLModel * XPMP2::CSLModelByPkgShortId ( std::uint16_t  _pkgHash,
const std::string &  _shortId 
)

Find a model by package name hash and short id.

This approach is used by the remote client to safe network bandwith. If an exact match with pkgHash and shortID is not found, then a model matching the short id alone is returned if available.

Note
This is directly used by XPMP2-Remote client with a potentially limited short id string

◆ CSLModelGetKeyStr()

std::string XPMP2::CSLModelGetKeyStr ( int  _related,
const std::string &  _type,
const std::string &  _id 
)

◆ CSLModelMatching()

int XPMP2::CSLModelMatching ( const std::string &  _type,
const std::string &  _airline,
const std::string &  _livery,
CSLModel *&  pModel 
)

Find a matching model.

Matching happens usually in just one pass by calling CSLFindMatch().
The only exception is if the passed-in aircraft type is not an official ICAO type (which is what doc8643-matching bases on). In that case, the first pass is done without doc8643-matching. If that pass found no actual match, then there is a second pass based on the default ICAO type.

Parameters
_typeICAO aircraft type like "A319"
_airlineICAO airline code like "DLH"
_liveryAny specific livery code, in LiveTraffic e.g. the tail number
[out]pModelReceives the pointer to the matching CSL model, or NULL if nothing found
Returns
The number of passes needed to find a match, the lower the better the quality, negative is error.

◆ CSLModelsAdd()

void XPMP2::CSLModelsAdd ( CSLModel _csl)

Adds a readily defined CSL model to all the necessary maps, resets passed-in reference.

◆ CSLModelsCleanup()

void XPMP2::CSLModelsCleanup ( )

Grace cleanup.

◆ CSLModelsConvPackagePath()

std::string XPMP2::CSLModelsConvPackagePath ( const std::string &  pkgPath,
int  lnNr,
bool  bPkgOptional = false 
)

Turn a relative package path into a full path.

Turns a relative package path in xsb_aircraft.txt (like "__Bluebell_Airbus:A306/A306_AAW.obj") into a full path pointing to a concrete file and verifies the file's existence.

Returns
Empty if any validation fails, otherwise a full path to an existing .obj file

◆ CSLModelsFindPkgs()

const char* XPMP2::CSLModelsFindPkgs ( const std::string &  _path,
std::vector< std::string > &  paths,
int  _maxDepth = 5 
)

Recursively scans folders to find xsb_aircraft.txt files of CSL packages.

Parameters
_pathThe path to start the search in
[out]pathsList of paths in which an xsb_aircraft.txt file has actually been found
_maxDepthHow deep into the folder hierarchy shall we search? (defaults to 5)

◆ CSLModelsInit()

void XPMP2::CSLModelsInit ( )

Initialization.

◆ CSLModelsLoad()

const char * XPMP2::CSLModelsLoad ( const std::string &  _path,
int  _maxDepth = 5 
)

Read the CSL Models found in the given path and below.

Parameters
_pathPath to a folder, which will be searched hierarchically for xsb_aircraft.txt files
_maxDepthSearch shall go how many folders deep at max?
Returns
An empty string on success, otherwise a human-readable error message

◆ CSLModelsProcessAcFile()

const char* XPMP2::CSLModelsProcessAcFile ( const std::string &  path)

Process one xsb_aircraft.txt file for importing OBJ8 models.

◆ CSLModelsReadPkgId()

const char* XPMP2::CSLModelsReadPkgId ( const std::string &  path)

Scans an xsb_aircraft.txt file for EXPORT_NAME entries to fill the list of packages.

◆ deg2rad()

template<class T >
T XPMP2::deg2rad ( const T  _deg)
inline

Convert degree to radians.

◆ dist()

template<class T >
T XPMP2::dist ( const T  x1,
const T  y1,
const T  z1,
const T  x2,
const T  y2,
const T  z2 
)
inline

Pythagorean distance between two points in a 3-D world.

◆ Doc8643Get()

const Doc8643 & XPMP2::Doc8643Get ( const std::string &  _type)

Return a reference to the matching Doc8643 object.

Returns
If no match can be found a reference to a standard empty object is returned.

◆ Doc8643IsTypeValid()

bool XPMP2::Doc8643IsTypeValid ( const std::string &  _type)

Is the given aircraft type a valid ICAO type as per Doc8643?

◆ Doc8643Load()

const char * XPMP2::Doc8643Load ( const std::string &  _path)

Load the content of the provided Doc8643.txt file.

◆ ExistsFile()

bool XPMP2::ExistsFile ( const std::string &  filename)

Does a file path exist?

See also
https://stackoverflow.com/a/51301928

◆ FROMPOSIX()

std::string XPMP2::FROMPOSIX ( const std::string &  p)
inline

On Lin/Win there is no need for a conversion, but we do treat p now as std::string

◆ GetDirContents()

std::list< std::string > XPMP2::GetDirContents ( const std::string &  path)

List of files in a directory (wrapper around XPLMGetDirectoryContents)

◆ GetGraphicsDriverTxt()

const char * XPMP2::GetGraphicsDriverTxt ( )

Text string for current graphics driver in use.

◆ GetMiscNetwTime()

float XPMP2::GetMiscNetwTime ( )

Get synched network time from X-Plane (sim/network/misc/network_time_sec) as used in Log.txt.

◆ GetMiscNetwTimeStr()

std::string XPMP2::GetMiscNetwTimeStr ( float  _time = NAN)

Return the network time as a string like used in the XP's Log.txt.

Parameters
_timeIf given convert that time, otherwise convert XPMP2::GetMiscNetwTime()

◆ GetXPSystemPath()

const std::string & XPMP2::GetXPSystemPath ( )

Returns XP's system directory, including a trailing slash.

◆ glockRmtData()

std::unique_lock<std::mutex> XPMP2::glockRmtData ( gmutexRmtData  )

The lock that we keep during handling of the flight loop.

◆ GoTCASOverride()

bool XPMP2::GoTCASOverride ( )
inline

Are we going to new (TCAS override) or the old way?

◆ headDiff()

float XPMP2::headDiff ( float  head1,
float  head2 
)

(Shortest) difference between 2 angles: How much to turn to go from h1 to h2?

◆ headNormalize()

template<class numT >
numT XPMP2::headNormalize ( numT  _head)

Normalize a heading value to [0..360), works for both float and double values.

◆ IsDir()

bool XPMP2::IsDir ( const std::string &  path)

Is path a directory?

◆ IsInRect()

bool XPMP2::IsInRect ( float  x,
float  y,
const float  bounds_ltrb[4] 
)

Tests if x/y lies within the rect, given as a float[4] array.

◆ iterRnd()

template<class IteratorT >
IteratorT XPMP2::iterRnd ( IteratorT  lower,
IteratorT  upper 
)

Returns any random value in the range [cslLower; cslUpper), or upper if there is no value in that range.

◆ LogGetString()

const char * XPMP2::LogGetString ( const char *  szPath,
int  ln,
const char *  szFunc,
logLevelTy  lvl,
const char *  szMsg,
va_list  args 
)

Returns ptr to static buffer filled with formatted log string.

◆ LogMsg()

void XPMP2::LogMsg ( const char *  szPath,
int  ln,
const char *  szFunc,
logLevelTy  lvl,
const char *  szMsg,
  ... 
)

Log Text to log file.

◆ ltrim()

std::string& XPMP2::ltrim ( std::string &  s,
const char *  t = WHITESPACE 
)
inline

◆ MapCleanup()

void XPMP2::MapCleanup ( )

Grace cleanup.

◆ MapCreateAll()

void XPMP2::MapCreateAll ( )

Loop all existing maps and create our map layer for them.

◆ MapCreateCB()

void XPMP2::MapCreateCB ( const char *  mapIdentifier,
void *   
)

Callback called when a map is created. We then need to add our layer to it.

◆ MapDeleteCB()

void XPMP2::MapDeleteCB ( XPLMMapLayerID  inLayer,
void *   
)

Called when a map is about to be deleted.

◆ MapDestroyAll()

void XPMP2::MapDestroyAll ( )

Remove all our map layers.

◆ MapIconDrawingCB()

void XPMP2::MapIconDrawingCB ( XPLMMapLayerID  inLayer,
const float *  inMapBoundsLeftTopRightBottom,
float  ,
float  mapUnitsPerUserInterfaceUnit,
XPLMMapStyle  ,
XPLMMapProjectionID  projection,
void *  refcon 
)

Actually draw the icons into the map.

This call computes the labels location on the map and puts this info into the aircraft object. MapLabelDrawingCB() reuses the cached location info.

◆ MapInit()

void XPMP2::MapInit ( )

Initialize the module.

◆ MapLabelDrawingCB()

void XPMP2::MapLabelDrawingCB ( XPLMMapLayerID  inLayer,
const float *  inMapBoundsLeftTopRightBottom,
float  ,
float  mapUnitsPerUserInterfaceUnit,
XPLMMapStyle  ,
XPLMMapProjectionID  projection,
void *  refcon 
)

Actually draw the labels into th emap.

◆ MapLayerCreate()

void XPMP2::MapLayerCreate ( const char *  mapIdentifier)

Create our map layer for the given map.

◆ MapPrepareCacheCB()

void XPMP2::MapPrepareCacheCB ( XPLMMapLayerID  ,
const float *  inTotalMapBoundsLeftTopRightBottom,
XPLMMapProjectionID  projection,
void *   
)

Prepare map drawing information.

It seems that XPLMMapScaleMeter only works from here, otherwise could crash the sim. (Reported as bug to Laminar)

◆ NetwGetLocalAddresses()

const std::vector< InetAddrTy > & XPMP2::NetwGetLocalAddresses ( )

Return all local addresses (also cached locally)

◆ NetwIsLocalAddr() [1/2]

bool XPMP2::NetwIsLocalAddr ( const InetAddrTy addr)

Is given address a local one?

◆ NetwIsLocalAddr() [2/2]

bool XPMP2::NetwIsLocalAddr ( const sockaddr *  sa)
inline

Is given address a local one?

◆ Obj8DataRefsLoad()

const char * XPMP2::Obj8DataRefsLoad ( const std::string &  _path)

Load the content of the provided Obj8DataRefs.txt file.

◆ PJWHash16()

std::uint16_t XPMP2::PJWHash16 ( const char *  s)

Produces a reproducible(!) hash value for strings.

Result is the same if the same string is provided, across platform and across executions, unlike what std::hash requires.
It is implemented as a 16-bit version of the PJW hash:

See also
https://en.wikipedia.org/wiki/PJW_hash_function

◆ PrefsFuncFloatDefault()

float XPMP2::PrefsFuncFloatDefault ( const char *  ,
const char *  ,
float  _default 
)

◆ PrefsFuncIntDefault()

int XPMP2::PrefsFuncIntDefault ( const char *  ,
const char *  ,
int  _default 
)

Default config function just always returns the provided default value.

◆ rad2deg()

template<class T >
T XPMP2::rad2deg ( const T  _rad)
inline

Convert radians to degrees, normalized to [0..360)

◆ RelatedGet()

int XPMP2::RelatedGet ( const std::string &  _acType)

Find the related group for an ICAO a/c type, 0 if none.

◆ RelatedLoad()

const char * XPMP2::RelatedLoad ( const std::string &  _path)

Read the related.txt file, full path passed in.

◆ RemoteAcClearAll()

void XPMP2::RemoteAcClearAll ( )

Informs us that there are no more aircraft, clear our caches!

◆ RemoteAcEnqueue()

void XPMP2::RemoteAcEnqueue ( const Aircraft ac)

Regularly called from the flight loop callback to send a/c date onto the network.

Will collect data into network messages but only send out when full

◆ RemoteAcEnqueueDone()

void XPMP2::RemoteAcEnqueueDone ( )

Informs us that all a/c have been processed: All pending messages to be sent now.

◆ RemoteAcEnqueueStarts()

void XPMP2::RemoteAcEnqueueStarts ( float  now)

Informs us that updating a/c will start now, do some prep work

Note
Internally acquires a lock, XPMP2::RemoteAcEnqueueDone() must be called to release that lock

◆ RemoteAcRemove()

void XPMP2::RemoteAcRemove ( const Aircraft ac)

Informs us about an aircraft deletion.

◆ RemoteCleanup()

void XPMP2::RemoteCleanup ( )

Grace cleanup, stops all threads.

◆ RemoteGetStatus()

RemoteStatusTy XPMP2::RemoteGetStatus ( )

Returns the current Remote status.

◆ RemoteInit()

void XPMP2::RemoteInit ( )

Initialize the module.

◆ RemoteRecvStart()

void XPMP2::RemoteRecvStart ( const RemoteCBFctTy _rmtCBFcts)

Starts the listener, will call provided callback functions with received messages.

◆ RemoteRecvStop()

void XPMP2::RemoteRecvStop ( )

Stops the receiver.

◆ RemoteSenderUpdateStatus()

void XPMP2::RemoteSenderUpdateStatus ( )

Compares current vs. expected status and takes appropriate action.

◆ RemoveExtension()

void XPMP2::RemoveExtension ( std::string &  path)

Removes everything after the last dot, the dot including.

◆ RmtRecvContinue()

bool XPMP2::RmtRecvContinue ( )
inline

Conditions for continued receive operation.

◆ RmtRecvMain()

void XPMP2::RmtRecvMain ( )

Thread main function for the receiver.

◆ RmtSendBeacon()

void XPMP2::RmtSendBeacon ( )

Sends an Interest Beacon.

◆ RmtSendContinue()

bool XPMP2::RmtSendContinue ( )
inline

Conditions for continued send operation.

◆ RmtSendLoop()

void XPMP2::RmtSendLoop ( )

Sending function, ie. we are actively sending data out.

◆ RmtSendMain()

void XPMP2::RmtSendMain ( )

Thread main function for the sender.

◆ RmtSendProcessQueue()

void XPMP2::RmtSendProcessQueue ( )

Process the data passed down to us in the queue.

◆ RmtSendSettings()

void XPMP2::RmtSendSettings ( )

Send our settings.

◆ RmtStartMCThread()

void XPMP2::RmtStartMCThread ( bool  bSender)

Start the background thread to listen to multicast, to see if anybody is interested in our data.

◆ RmtStopAll()

void XPMP2::RmtStopAll ( )

Stop all threads and communication with the network.

◆ rtrim()

std::string& XPMP2::rtrim ( std::string &  s,
const char *  t = WHITESPACE 
)
inline

◆ safeGetline()

std::istream & XPMP2::safeGetline ( std::istream &  is,
std::string &  t 
)

Read a line from a text file, no matter if ending on CRLF or LF.

Read a text line, handling both Windows (CRLF) and Unix (LF) ending Code makes use of the fact that in both cases LF is the terminal character. So we read from file until LF (without widening!). In case of CRLF files there then is a trailing CR, which we just remove.

◆ sqr()

template<class T >
T XPMP2::sqr ( const T  a)
inline

Square.

◆ str_tokenize()

std::vector< std::string > XPMP2::str_tokenize ( const std::string  s,
const std::string  tokens,
bool  bSkipEmpty 
)

separates string into tokens

◆ str_tolower()

std::string & XPMP2::str_tolower ( std::string &  s)

change a std::string to uppercase

◆ StrCntString()

int XPMP2::StrCntString ( const mapStrIntTy m,
std::string &  s 
)

Compiles a string from a map of string->int like "(A320 x 5, A388 x 12)".

Returns
Total count (17 in the example above)

◆ StripXPSysDir()

std::string XPMP2::StripXPSysDir ( const std::string &  path)

If a path starts with X-Plane's system directory it is stripped.

◆ TOPOSIX()

std::string XPMP2::TOPOSIX ( const std::string &  p)
inline

On Lin/Win there is no need for a conversion, but we do treat p now as std::string

◆ trim()

std::string& XPMP2::trim ( std::string &  s,
const char *  t = WHITESPACE 
)
inline

◆ TwoDActivate()

void XPMP2::TwoDActivate ( )

Activate actual label drawing, esp. set up drawing callback.

◆ TwoDCleanup()

void XPMP2::TwoDCleanup ( )

Grace cleanup.

◆ TwoDDeactivate()

void XPMP2::TwoDDeactivate ( )

Deactivate actual label drawing, esp. stop drawing callback.

◆ TwoDDrawLabels()

void XPMP2::TwoDDrawLabels ( )

Write the labels of all aircraft.

See also
This code bases on the last part of XPMPDefaultPlaneRenderer of the original libxplanemp
Author
Ben Supnik, Chris Serio, Chris Collins, Birger Hoppe

◆ TwoDInit()

void XPMP2::TwoDInit ( )

Initialize the module.

◆ XPMPSendNotification()

void XPMP2::XPMPSendNotification ( const Aircraft plane,
XPMPPlaneNotification  _notification 
)

Send a notification to all observers.

◆ XPMPValidateResourceFiles()

const char* XPMP2::XPMPValidateResourceFiles ( const char *  resourceDir)

Validate all required files are available in the resource directory.

Variable Documentation

◆ ahDataRefs

std::vector<XPLMDataRef> XPMP2::ahDataRefs

Registered dataRefs.

◆ AI_PRIO_MULTIPLIER

constexpr int XPMP2::AI_PRIO_MULTIPLIER = 10 * M_per_NM
constexpr

How much distance does each AIPrio add?

◆ AISLOT_CHANGE_PERIOD

constexpr float XPMP2::AISLOT_CHANGE_PERIOD = 15.0f
constexpr

How often do we reassign AI slots? [seconds].

◆ ALL_MAPS

std::array<const char*, 2> XPMP2::ALL_MAPS
Initial value:
= {
XPLM_MAP_USER_INTERFACE,
XPLM_MAP_IOS,
}

The list of known maps, which are hard-coded by X-Plane's SDK.

◆ DATA_REF_EDITORS

const char* XPMP2::DATA_REF_EDITORS[]
Initial value:
= {
"xplanesdk.examples.DataRefEditor",
"com.leecbaker.datareftool"
}

◆ DOC8643_EMPTY

const Doc8643 XPMP2::DOC8643_EMPTY

◆ drStrings

std::vector<std::unique_ptr<std::string> > XPMP2::drStrings

Here we store the dataRef strings as smart pointers, so that the pointed-to location will not change but we can easily manage them

◆ ERR_CFG_FILE_MAXWARN

constexpr int XPMP2::ERR_CFG_FILE_MAXWARN = 5
constexpr

Maximum number of warnings during file read before bailing.

◆ F_NULL

float XPMP2::F_NULL[10] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}

A constant array of zero values supporting quick array initialization.

◆ FAR_AWAY_VAL_GL

constexpr float XPMP2::FAR_AWAY_VAL_GL = 9999999.9f
constexpr

Don't dare using NAN...but with this coordinate for x/y/z a plane should be far out and virtually invisible.

◆ gaddrLocal

std::vector<InetAddrTy> XPMP2::gaddrLocal

List of local IP addresses.

◆ GARBAGE_COLLECTION_PERIOD

constexpr float XPMP2::GARBAGE_COLLECTION_PERIOD = 60.0f
constexpr

How often to call the garbage collection [s].

◆ GARBAGE_COLLECTION_TIMEOUT

constexpr float XPMP2::GARBAGE_COLLECTION_TIMEOUT = 180.0f
constexpr

Unload an unused object after how many seconds?

◆ gbStopMCThread

volatile bool XPMP2::gbStopMCThread = false

Shall the network thread stop?

◆ gCntMCErr

int XPMP2::gCntMCErr = 0

error counter for network thread

◆ gcvRmtData

std::condition_variable XPMP2::gcvRmtData

notifies the network thread of available data to be processed

◆ gFlightLoopID

XPLMFlightLoopID XPMP2::gFlightLoopID = nullptr

The id of our flight loop callback.

◆ gFullUpdDue

unsigned XPMP2::gFullUpdDue = 0

What's the full update group that has its turn now?

◆ gFullUpdLastDone

unsigned XPMP2::gFullUpdLastDone = 0

the last actually processed full update group

◆ gGarbageCollectionID

XPLMFlightLoopID XPMP2::gGarbageCollectionID = nullptr

The ids of our garbage collection flight loop callback.

◆ glob

GlobVars XPMP2::glob

The one and only global variable structure.

◆ gmapRmtAcCache

mapRmtAcCacheTy XPMP2::gmapRmtAcCache

Cache for last data sent out to the network.

◆ gMsgAcAnim

A/C Animation dataRefs message.

◆ gMsgAcDetail

A/C Detail message.

◆ gMsgAcPosUpdate

A/C Position Update message.

◆ gMsgAcRemove

A/C Removal message.

◆ gmutexRmtData

std::mutex XPMP2::gmutexRmtData

protects modifying access to the queue and the condition variable

◆ gNow

float XPMP2::gNow = 0.0f

Current network timestamp.

◆ gNxtFullUpdGrpToAssign

unsigned XPMP2::gNxtFullUpdGrpToAssign = 0

What's the next group number to assign to the next a/c? (Assigned will be the value incremented by 1)

◆ gNxtTxfTime

float XPMP2::gNxtTxfTime = 0.0f

When to actually process position updates next?

◆ gpMc

UDPMulticast* XPMP2::gpMc = nullptr

multicast socket for listening/sending (destructor uses locks, which don't work during module shutdown, so can't create a global object due to its exit-time destructor)

◆ gqueueRmtData

queueRmtDataTy XPMP2::gqueueRmtData

the queue for passing data from main to network thread

◆ gRmtCBFcts

RemoteCBFctTy XPMP2::gRmtCBFcts

The callback function pointers the remote client plugin provided.

◆ gSendSettingsLast

float XPMP2::gSendSettingsLast = 0.0f

Timestamp when we sent our settings the last time.

◆ gThrMC

std::thread XPMP2::gThrMC

remote listening/sending thread

◆ INVALID_SOCKET

constexpr SOCKET XPMP2::INVALID_SOCKET = -1
constexpr

◆ LOG_LEVEL

const char* XPMP2::LOG_LEVEL[]
Initial value:
= {
"DEBUG", "INFO ", "WARN ", "ERROR", "FATAL", "MSG "
}

◆ M_per_FT

constexpr double XPMP2::M_per_FT = 0.3048
constexpr

Convert feet to meters, e.g. for altitude calculations.

◆ M_per_NM

constexpr int XPMP2::M_per_NM = 1852
constexpr

Convert nautical miles to meters.

◆ MAP_AC_SIZE

constexpr float XPMP2::MAP_AC_SIZE = 30.0f
constexpr

Assumed size of an aircraft in m.

◆ MAP_ICON_HEIGHT

constexpr int XPMP2::MAP_ICON_HEIGHT = 3
constexpr

Dimenson of MapIcon.png.

◆ MAP_ICON_WIDTH

constexpr int XPMP2::MAP_ICON_WIDTH = 3
constexpr

Dimenson of MapIcon.png.

◆ MAP_MIN_ICON_SIZE

constexpr int XPMP2::MAP_MIN_ICON_SIZE = 40
constexpr

Minimum icon size in map in UI units.

◆ MC_MAX_ERR

constexpr int XPMP2::MC_MAX_ERR =5
constexpr

after this many errors we no longer try listening

◆ mtxSocketClose

std::recursive_mutex XPMP2::mtxSocketClose

Mutex to ensure closing is done in one thread only to avoid race conditions on deleting the buffer.

◆ PACKED

◆ PI

constexpr double XPMP2::PI = 3.1415926535897932384626433832795028841971693993751
constexpr

Pi.

◆ REMOTE_ALT_FT_RES

constexpr double XPMP2::REMOTE_ALT_FT_RES = 0.01
constexpr

resolution of altitude[ft] updates

◆ REMOTE_DEGREE_RES

constexpr double XPMP2::REMOTE_DEGREE_RES = 0.00000001
constexpr

What is the maximum difference a RemoteAcPosUpdateTy can hold?

resolution of degree updates

◆ REMOTE_DR_DEF

const std::array< RemoteDataRefPackTy, V_COUNT > XPMP2::REMOTE_DR_DEF

An array holding all dataRef packing definitions.

Defines per dataRef the value range we support transferring to the remote client.

◆ REMOTE_MAX_DIFF_ALT_FT

constexpr double XPMP2::REMOTE_MAX_DIFF_ALT_FT = REMOTE_ALT_FT_RES * INT16_MAX
constexpr

maximum altitude[ft] difference that can be represented in a pos update msg

◆ REMOTE_MAX_DIFF_DEGREE

constexpr double XPMP2::REMOTE_MAX_DIFF_DEGREE = REMOTE_DEGREE_RES * INT16_MAX
constexpr

maximum degree difference that can be represented in a pos update msg

◆ REMOTE_MAX_DIFF_TIME

constexpr float XPMP2::REMOTE_MAX_DIFF_TIME = REMOTE_TIME_RES * UINT16_MAX
constexpr

maximum time difference thatn can be represented in a pos update msg

◆ REMOTE_RECV_BEACON_INTVL

constexpr int XPMP2::REMOTE_RECV_BEACON_INTVL = 15
constexpr

How often to send an Interest Beacon? [s].

◆ REMOTE_SEND_AC_DETAILS_INTVL

constexpr float XPMP2::REMOTE_SEND_AC_DETAILS_INTVL = 10.f
constexpr

How often to send full a/c details? [s].

◆ REMOTE_SEND_SETTINGS_INTVL

constexpr int XPMP2::REMOTE_SEND_SETTINGS_INTVL = 20
constexpr

How often to send settings? [s].

◆ REMOTE_SIGNATURE

constexpr const char* XPMP2::REMOTE_SIGNATURE = "TwinFan.plugin.XPMP2.Remote"
constexpr

The signature of the XPMP2 Remote Client.

◆ REMOTE_TIME_RES

constexpr float XPMP2::REMOTE_TIME_RES = 0.0001f
constexpr

resolution of time difference

◆ RMT_VER_AC_ANIM

constexpr std::uint8_t XPMP2::RMT_VER_AC_ANIM = 0
constexpr

A/C Position update message version number.

◆ RMT_VER_AC_DETAIL

constexpr std::uint8_t XPMP2::RMT_VER_AC_DETAIL = 1
constexpr

A/C detail message version number.

◆ RMT_VER_AC_POS_UPDATE

constexpr std::uint8_t XPMP2::RMT_VER_AC_POS_UPDATE = 0
constexpr

A/C Position update message version number.

◆ RMT_VER_AC_REMOVE

constexpr std::uint8_t XPMP2::RMT_VER_AC_REMOVE = 0
constexpr

A/C removal message version number.

◆ RMT_VER_BEACON

constexpr std::uint8_t XPMP2::RMT_VER_BEACON = 0
constexpr

Interest Beacon message version number.

◆ RMT_VER_SETTINGS

constexpr std::uint8_t XPMP2::RMT_VER_SETTINGS = 0
constexpr

Setttings message version number.

◆ RPM_to_RADs

constexpr float XPMP2::RPM_to_RADs = 0.10471975511966f
constexpr

Convert revolutions-per-minute (RPM) to radians per second (rad/s) by multiplying with PI/30.

◆ RSRC_DOC8643

constexpr const char* XPMP2::RSRC_DOC8643 = "Doc8643.txt"
constexpr

◆ RSRC_MAP_ICONS

constexpr const char* XPMP2::RSRC_MAP_ICONS = "MapIcons.png"
constexpr

◆ RSRC_OBJ8DATAREFS

constexpr const char* XPMP2::RSRC_OBJ8DATAREFS = "Obj8DataRefs.txt"
constexpr

◆ RSRC_RELATED

constexpr const char* XPMP2::RSRC_RELATED = "related.txt"
constexpr

◆ SDR_CSLMODEL_TXT_SIZE

constexpr size_t XPMP2::SDR_CSLMODEL_TXT_SIZE = 40
constexpr

Number of characters to be allowed for CSL model text.

◆ SERR_LEN

constexpr size_t XPMP2::SERR_LEN = 100
constexpr

Maximum length of OS error message.

◆ vecDREdataRefStr

std::vector<std::string> XPMP2::vecDREdataRefStr

list of dataRef strings to be send to the editors

◆ XPLM_PHASE_AIRPLANES

constexpr int XPMP2::XPLM_PHASE_AIRPLANES = 25
constexpr

The drawing phase "xplm_Phase_Airplanes" is deprecated in XP11.50 upwards, but we need it in earlier versions to fake TCAS.

◆ XPMP2_VER

constexpr float XPMP2::XPMP2_VER = 2.30f
constexpr

XPMP2 version number.