-
Notifications
You must be signed in to change notification settings - Fork 25
/
DataRefs.h
1088 lines (949 loc) · 52.8 KB
/
DataRefs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/// @file DataRefs.h
/// @brief Access to global data like dataRefs, `doc8643` and `model_typecode` files.
/// @details Defines classes Doc8643, DataRefs, and read access to `model_typecode` file.\n
/// There is exactly one instance of DataRefs, which is the global variable `dataRefs`,
/// in which all globally relevant values are stored, beyond just XP's dataRefs:\n
/// - LiveTraffic's configuration options including reading/writing of the config file\n
/// - readable callbacks for other plugins' access to LiveTraffic's data
/// - LTAPI interface
/// @author Birger Hoppe
/// @copyright (c) 2018-2020 Birger Hoppe
/// @copyright Permission is hereby granted, free of charge, to any person obtaining a
/// copy of this software and associated documentation files (the "Software"),
/// to deal in the Software without restriction, including without limitation
/// the rights to use, copy, modify, merge, publish, distribute, sublicense,
/// and/or sell copies of the Software, and to permit persons to whom the
/// Software is furnished to do so, subject to the following conditions:\n
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.\n
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
#ifndef DataRefs_h
#define DataRefs_h
#include "XPLMDataAccess.h"
#include "TextIO.h"
#include "CoordCalc.h"
class RealTrafficConnection;
//
// MARK: Defaults
//
const int DEF_MAX_NUM_AC = 50; ///< how many aircraft to create at most?
const int DEF_FD_STD_DISTANCE = 25; ///< nm: miles to look for a/c around myself
const int DEF_FD_SNAP_TAXI_DIST = 15; ///< [m]: Snapping to taxi routes in a max distance of this many meter (0 -> off)
const int DEF_FD_REFRESH_INTVL = 20; ///< how often to fetch new flight data
const int DEF_FD_LONG_REFR_INTVL= 60; ///< how often to fetch new flight data if flying high
const int DEF_FD_BUF_PERIOD = 90; ///< seconds to buffer before simulating aircraft
const int DEF_FD_REDUCE_HEIGHT = 10000; ///< height AGL considered "flying high"
const int DEF_CONTR_ALT_MIN = 25000; ///< [ft] Auto Contrails: Minimum altitude
const int DEF_CONTR_ALT_MAX = 45000; ///< [ft] Auto Contrails: Maximum altitude
const int DEF_CONTR_LIFETIME = 25; ///< [s] Contrail default time to live
const bool DEF_CONTR_MULTI = false; ///< Auto-create multiple or just a single contrail?
#if LIN // On Linux, there more reports of issues if using separate FMOD, so we keep it disabled by default:
const bool DEF_SND_FMOD_INST = false; ///< Enforce using our own FMOD instance instead of X-Plane's?
#else // There have been various CTD reports with complex aircraft if using X-Plane's FMOD, so we keep this enabled by default:
const bool DEF_SND_FMOD_INST = true; ///< Enforce using our own FMOD instance instead of X-Plane's?
#endif
const int DEF_SUI_TRANSP = 0; ///< Settings UI: transaprent background?
const int DEF_MAX_NETW_TIMEOUT = 5; ///< [s] default maximum network request timeout
constexpr int DEF_UI_FONT_SCALE = 100; ///< [%] Default font scaling
constexpr int DEF_UI_OPACITY = 25; ///< [%] Default background opacity
//
// MARK: Doc8643
//
class Doc8643 {
public:
std::string manufacturer;
std::string model;
std::string typeDesignator;
std::string classification;
std::string wtc;
public:
Doc8643 () {}
Doc8643 (std::string&& _manufacturer,
std::string&& _model,
std::string&& _typeDesignator,
std::string&& _classification,
std::string&& _wtc);
// copying and moving is all as per default
public:
Doc8643 (const Doc8643& o) = default;
Doc8643 (Doc8643&& o) = default;
Doc8643& operator = (const Doc8643& o) = default;
Doc8643& operator = (Doc8643&& o) = default;
// 'model' is key, so let's base all comparison on it
public:
bool operator == (const Doc8643& o) const { return model == o.model; }
bool operator < (const Doc8643& o) const { return model < o.model; }
bool operator > (const Doc8643& o) const { return model > o.model; }
operator bool () const { return !model.empty(); }
// return the string for FlightModel matching
operator std::string() const;
// Helicopter or Gyrocopter with big rotor?
inline bool hasRotor () const
{ return classification.size() >= 1 ?
(classification[0] == 'H' || classification[0] == 'G') : false;
}
// static functions for reading the doc8643.txt file
// and returning information from it
public:
static bool ReadDoc8643File ();
static const Doc8643& get (const std::string& _type);
};
//
// MARK: ModelIcaoType
//
/// @brief Represents an entry in the `model_typecode.txt` file
/// @details The `model_typecode.txt` file matches
/// non-standardized human-readable `model` entries in
/// tracking data (especially in OpenSky's data) to an ICAO a/c type code.
/// The file has been created by forum user crbascott.
/// @see https://forums.x-plane.org/index.php?/forums/topic/188206-matching-lacks-icao-ac-type-code/
namespace ModelIcaoType
{
/// Read the `model_typecode.txt` file
bool ReadFile ();
/// Lookup ICAO type designator for human-readable model text, empty if nothing found
const std::string& getIcaoType (const std::string& _model);
}
//
// MARK: Screen coordinate helpers
//
/// 2D window position
struct WndPos {
int x = 0;
int y = 0;
/// Shift both values
void shift (int _dx, int _dy) { x += _dx; y += _dy; }
/// Return a shifted copy
WndPos shiftedBy (int _dx, int _dy) const
{ WndPos ret = *this; ret.shift(_dx,_dy); return ret; }
};
/// 2D rectagle
struct WndRect {
WndPos tl; ///< top left
WndPos br; ///< bottom right
/// Default Constructor -> all zero
WndRect () {}
/// Constructor takes four ints as a convenience
WndRect (int _l, int _t, int _r, int _b) :
tl{_l, _t}, br{_r, _b} {}
/// Constructor taking two positions
WndRect (const WndPos& _tl, const WndPos& _br) :
tl(_tl), br(_br) {}
// Accessor to individual coordinates
int left () const { return tl.x; } ///< reading left
int& left () { return tl.x; } ///< writing left
int top () const { return tl.y; } ///< reading top
int& top () { return tl.y; } ///< writing top
int right () const { return br.x; } ///< reading right
int& right () { return br.x; } ///< writing right
int bottom () const { return br.y; } ///< reading bottom
int& bottom () { return br.y; } ///< writing bottom
int width () const { return right() - left(); } ///< width
int height () const { return top() - bottom(); } ///< height
/// Does window contain the position?
bool contains (const WndPos& _p) const
{ return
left() <= _p.x && _p.x <= right() &&
bottom() <= _p.y && _p.y <= top(); }
/// Clear all to zero
void clear () { tl.x = tl.y = br.x = br.y = 0; }
/// Is all zeroes?
bool empty () const { return !tl.x && !tl.y && !br.x && !br.y; }
/// Shift position right/down
WndRect& shift (int _dx, int _dy)
{ tl.shift(_dx,_dy); br.shift(_dx,_dy); return *this; }
/// Set from config file string ("left,top,right.bottom")
void set (const std::string& _s);
/// Make sure the window is on the visible screen
bool keepOnScreen ();
};
/// Write WndRect into config file ("left,top,right.bottom")
std::ostream& operator<< (std::ostream& _stream, const WndRect& _r);
//
// MARK: DataRefs
//
// from LTAircraft.h
class LTAircraft;
enum pluginStateTy {
STATE_STOPPED = 0, // before init; after stop
STATE_INIT, // after init, before enabled; after disabled, before stop
STATE_ENABLED, // after enabled; before disabled
STATE_SHOW_AC // enabled + showing aircraft
};
// XP standard Datarefs being accessed
enum dataRefsXP {
DR_MISC_NETW_TIME = 0,
DR_LOCAL_TIME_SEC,
DR_LOCAL_DATE_DAYS,
DR_USE_SYSTEM_TIME,
DR_ZULU_TIME_SEC,
DR_REPLAY_MODE, ///< sim/operation/prefs/replay_mode int y enum Are we in replay mode?
DR_VIEW_EXTERNAL,
DR_VIEW_TYPE,
DR_MODERN_DRIVER, // sim/graphics/view/using_modern_driver: boolean: Vulkan/Metal in use?
DR_CAMERA_TCAS_IDX, ///< Shared data ref created by us: If LiveTraffic's camera is on, then on which aircraft? Here: TCAS index
DR_CAMERA_AC_ID, ///< Shared data ref created by us: If LiveTraffic's camera is on, then on which aircraft? Here: aircraft id (usually ICAO hex code)
DR_PLANE_LAT, // user's plane
DR_PLANE_LON,
DR_PLANE_ELEV,
DR_PLANE_AGL, ///< sim/flightmodel/position/y_agl float n meters AGL
DR_PLANE_PITCH,
DR_PLANE_ROLL,
DR_PLANE_HEADING,
DR_PLANE_MAG_HEADING, ///< sim/flightmodel/position/mag_psi float n degrees The real magnetic heading of the aircraft
DR_PLANE_TRACK,
DR_PLANE_KIAS, ///< sim/flightmodel/position/indicated_airspeed float y kias Air speed indicated - this takes into account air density and wind direction
DR_PLANE_TAS, ///< sim/flightmodel/position/true_airspeed float n meters/sec Air speed true - this does not take into account air density at altitude!
DR_PLANE_GS, ///< sim/flightmodel/position/groundspeed float n meters/sec The ground speed of the aircraft
DR_PLANE_VVI, ///< sim/flightmodel/position/vh_ind float n meters/second VVI (vertical velocity in meters per second)
DR_PLANE_ONGRND,
DR_PLANE_REG, ///< sim/aircraft/view/acf_tailnum byte[40] y string Tail number
DR_PLANE_MODES_ID, ///< sim/aircraft/view/acf_modeS_id int y integer 24bit (0-16777215 or 0-0xFFFFFF) unique ID of the airframe. This is also known as the ADS-B "hexcode".
DR_PLANE_ICAO, ///< sim/aircraft/view/acf_ICAO byte[40] y string ICAO code for aircraft (a string) entered by author
DR_VR_ENABLED, // VR stuff
CNT_DATAREFS_XP // always last, number of elements
};
enum cmdRefsXP {
CR_NO_COMMAND = -1, // initialization placeholder
CR_GENERAL_LEFT = 0, // first 16 commands grouped together
CR_GENERAL_RIGHT, // they move the spot on latitude (Z) and lonigtude (X)
CR_GENERAL_LEFT_FAST, // there actual movement twords Z and X depends on current heading
CR_GENERAL_RIGHT_FAST,
CR_GENERAL_FORWARD,
CR_GENERAL_BACKWARD,
CR_GENERAL_FORWARD_FAST,
CR_GENERAL_BACKWARD_FAST,
CR_GENERAL_HAT_SWITCH_LEFT, // hat switch
CR_GENERAL_HAT_SWITCH_RIGHT,
CR_GENERAL_HAT_SWITCH_UP,
CR_GENERAL_HAT_SWITCH_DOWN,
CR_GENERAL_HAT_SWITCH_UP_LEFT,
CR_GENERAL_HAT_SWITCH_UP_RIGHT,
CR_GENERAL_HAT_SWITCH_DOWN_LEFT,
CR_GENERAL_HAT_SWITCH_DOWN_RIGHT,
CR_GENERAL_UP, // up/down -> change altitude
CR_GENERAL_DOWN,
CR_GENERAL_UP_FAST,
CR_GENERAL_DOWN_FAST,
CR_GENERAL_ROT_LEFT, // rotate/turn -> change heading
CR_GENERAL_ROT_RIGHT,
CR_GENERAL_ROT_LEFT_FAST,
CR_GENERAL_ROT_RIGHT_FAST,
CR_GENERAL_ROT_UP, // rotate/tilt -> change pitch
CR_GENERAL_ROT_DOWN,
CR_GENERAL_ROT_UP_FAST,
CR_GENERAL_ROT_DOWN_FAST,
CR_GENERAL_ZOOM_IN, // zoom
CR_GENERAL_ZOOM_OUT,
CR_GENERAL_ZOOM_IN_FAST,
CR_GENERAL_ZOOM_OUT_FAST, // last command registered for camera movement
CR_VIEW_FREE_CAM, ///< sim/view/free_camera Free camera.
CR_VIEW_FWD_2D, ///< sim/view/forward_with_2d_panel Forward with 2-D panel.
CR_VIEW_FWD_HUD , ///< sim/view/forward_with_hud Forward with HUD.
CR_VIEW_FWD_NODISP , ///< sim/view/forward_with_nothing Forward with nothing.
CR_VIEW_EXT_LINEAR , ///< sim/view/linear_spot Linear spot.
CR_VIEW_EXT_STILL , ///< sim/view/still_spot Still spot.
CR_VIEW_EXT_RNWY , ///< sim/view/runway Runway.
CR_VIEW_EXT_CIRCLE , ///< sim/view/circle Circle.
CR_VIEW_EXT_TOWER , ///< sim/view/tower Tower.
CR_VIEW_EXT_RIDE , ///< sim/view/ridealong Ride-along.
CR_VIEW_EXT_WEAPON , ///< sim/view/track_weapon Track weapon.
CR_VIEW_EXT_CHASE , ///< sim/view/chase Chase.
CR_VIEW_FWD_3D , ///< sim/view/3d_cockpit_cmnd_look 3-D cockpit.
CNT_CMDREFS_XP // always last, number of elements
};
enum XPViewTypes {
VIEW_UNKNOWN = 0,
VIEW_FWD_2D = 1000, ///< sim/view/forward_with_2d_panel Forward with 2-D panel.
VIEW_EXT_TOWER = 1014, ///< sim/view/tower Tower.
VIEW_EXT_RNWY = 1015, ///< sim/view/runway Runway.
VIEW_EXT_CHASE = 1017, ///< sim/view/chase Chase.
VIEW_EXT_CIRCLE = 1018, ///< sim/view/circle Circle.
VIEW_EXT_STILL = 1020, ///< sim/view/still_spot Still spot.
VIEW_EXT_LINEAR = 1021, ///< sim/view/linear_spot Linear spot.
VIEW_FWD_HUD = 1023, ///< sim/view/forward_with_hud Forward with HUD.
VIEW_FWD_NODISP = 1024, ///< sim/view/forward_with_nothing Forward with nothing.
VIEW_FWD_3D = 1026, ///< sim/view/3d_cockpit_cmnd_look 3-D cockpit.
VIEW_FREE_CAM = 1028, ///< sim/view/free_camera Free camera
VIEW_EXT_RIDE = 1031, ///< sim/view/ridealong Ride-along.
};
// Datarefs offered by LiveTraffic
enum dataRefsLT {
// a/c information
DR_AC_KEY = 0, // a/c info read/write
DR_AC_NUM, // int a/c info
DR_AC_ON_GND,
DR_AC_PHASE,
DR_AC_LAT, // float a/c info
DR_AC_LON,
DR_AC_ALT,
DR_AC_HEADING,
DR_AC_ROLL,
DR_AC_PITCH,
DR_AC_SPEED,
DR_AC_VSI,
DR_AC_TERRAIN_ALT,
DR_AC_HEIGHT,
DR_AC_FLAPS,
DR_AC_GEAR,
DR_AC_LIGHTS_BEACON,
DR_AC_LIGHTS_STROBE,
DR_AC_LIGHTS_NAV,
DR_AC_LIGHTS_LANDING,
DR_AC_BEARING,
DR_AC_DIST, // last of a/c info
DR_AC_BULK_QUICK, // bulk a/c primarily for communication with LTAPI
DR_AC_BULK_EXPENSIVE, // similar, but for expensive data, should be called less often
DR_SIM_DATE,
DR_SIM_TIME,
DR_LT_VER, ///< LiveTraffic's version number, like 201 for v2.01
DR_LT_VER_DATE, ///< LiveTraffic's version date, like 20200430 for 30-APR-2020
// UI information
DR_UI_OPACITY,
DR_UI_FONT_SCALE,
DR_UI_SETTINGS_TRANSP,
DR_UI_ACI_COLLAPSED,
// configuration options
DR_CFG_AIRCRAFT_DISPLAYED,
DR_CFG_AUTO_START,
DR_CFG_MASTER_VOLUME,
DR_CFG_SND_FORCE_FMOD_INSTANCE,
DR_CFG_AI_ON_REQUEST,
DR_CFG_AI_UNDER_CONTROL,
DR_CFG_AI_NOT_ON_GND,
DR_CFG_LABELS,
DR_CFG_LABEL_SHOWN,
DR_CFG_LABEL_MAX_DIST,
DR_CFG_LABEL_VISIBILITY_CUT_OFF,
DR_CFG_LABEL_COL_DYN,
DR_CFG_LABEL_COLOR,
DR_CFG_LOG_LEVEL,
DR_CFG_MSG_AREA_LEVEL,
DR_CFG_LOG_LIST_LEN,
DR_CFG_MAX_NUM_AC,
DR_CFG_FD_STD_DISTANCE,
DR_CFG_FD_SNAP_TAXI_DIST,
DR_CFG_FD_REFRESH_INTVL,
DR_CFG_FD_LONG_REFRESH_INTVL,
DR_CFG_FD_BUF_PERIOD,
DR_CFG_FD_REDUCE_HEIGHT,
DR_CFG_MAX_NETW_TIMEOUT,
DR_CFG_LND_LIGHTS_TAXI,
DR_CFG_HIDE_BELOW_AGL,
DR_CFG_HIDE_TAXIING,
DR_CFG_HIDE_PARKING,
DR_CFG_HIDE_NEARBY_GND,
DR_CFG_HIDE_NEARBY_AIR,
DR_CFG_HIDE_IN_REPLAY,
DR_CFG_HIDE_STATIC_TWR,
DR_CFG_COPY_OBJ_FILES,
DR_CFG_CONTRAIL_MIN_ALT,
DR_CFG_CONTRAIL_MAX_ALT,
DR_CFG_CONTRAIL_LIFE_TIME,
DR_CFG_CONTRAIL_MULTIPLE,
DR_CFG_REMOTE_SUPPORT,
DR_CFG_EXTERNAL_CAMERA,
DR_CFG_LAST_CHECK_NEW_VER,
// debug options
DR_DBG_AC_FILTER,
DR_DBG_AC_POS,
DR_DBG_LOG_RAW_FD,
DR_DBG_MODEL_MATCHING,
DR_DBG_EXPORT_FD,
DR_DBG_EXPORT_USER_AC,
DR_DBG_EXPORT_NORMALIZE_TS,
DR_DBG_EXPORT_FORMAT,
// channel configuration options
DR_CFG_FSC_ENV,
DR_CFG_OGN_USE_REQUREPL,
DR_CFG_RT_LISTEN_PORT,
DR_CFG_RT_TRAFFIC_PORT,
DR_CFG_RT_WEATHER_PORT,
DR_CFG_RT_SIM_TIME_CTRL,
DR_CFG_RT_MAN_TOFFSET,
DR_CFG_RT_CONNECT_TYPE,
DR_CFG_FF_LISTEN_PORT,
DR_CFG_FF_SEND_PORT,
DR_CFG_FF_SEND_USER_PLANE,
DR_CFG_FF_SEND_TRAFFIC,
DR_CFG_FF_SEND_TRAFFIC_INTVL,
// channels, in ascending order of priority
DR_CHANNEL_FUTUREDATACHN_ONLINE, // placeholder, first channel
DR_CHANNEL_FORE_FLIGHT_SENDER,
DR_CHANNEL_SYNTHETIC,
DR_CHANNEL_FSCHARTER,
DR_CHANNEL_OPEN_GLIDER_NET,
DR_CHANNEL_ADSB_HUB,
DR_CHANNEL_OPEN_SKY_ONLINE,
DR_CHANNEL_OPEN_SKY_AC_MASTERDATA,
DR_CHANNEL_OPEN_SKY_AC_MASTERFILE,
DR_CHANNEL_ADSB_EXCHANGE_ONLINE,
DR_CHANNEL_REAL_TRAFFIC_ONLINE, // currently highest-prio channel
// always last, number of elements:
CNT_DATAREFS_LT
};
enum cmdRefsLT {
CR_INFO_LIST_WND = 0,
CR_ACINFOWND_OPEN,
CR_ACINFOWND_OPEN_POPPED_OUT,
CR_ACINFOWND_HIDE_SHOW,
CR_ACINFOWND_CLOSE_ALL,
CR_AC_DISPLAYED,
CR_AC_TCAS_CONTROLLED,
CR_LABELS_TOGGLE,
CR_TOGGLE_AC_AHEAD, ///< Toggle visibility of the a/c ahead
CR_SETTINGS_UI,
CNT_CMDREFS_LT // always last, number of elements
};
/// Which format to use for exporting flight tracking data
enum exportFDFormat {
EXP_FD_AITFC = 1, ///< use AITFC format, the older shorter format
EXP_FD_RTTFC, ///< user RTTFC format, introduced with RealTraffic v9
};
/// Which simulator time to send to RealTraffic?
enum SimTimeCtrlTy : int {
STC_NO_CTRL = 0, ///< Don't send any sim time
STC_SIM_TIME_MANUALLY, ///< Send current sim time unchanged
STC_SIM_TIME_PLUS_BUFFER, ///< Send current sim time plus buffering period, so that the traffic, when it appears, matches up with current sim time
};
/// Which RealTraffic connection type to use?
enum RTConnTypeTy : int {
RT_CONN_REQU_REPL = 0, ///< Expect a license and use request/reply
RT_CONN_APP, ///< Expect the app to run and listen on UDP
};
// first/last channel; number of channels:
constexpr int DR_CHANNEL_FIRST = DR_CHANNEL_FUTUREDATACHN_ONLINE;
constexpr int DR_CHANNEL_LAST = CNT_DATAREFS_LT-1;
constexpr int CNT_DR_CHANNELS = DR_CHANNEL_LAST+1 - DR_CHANNEL_FIRST;
class DataRefs
{
public:
//MARK: dataRefDefinitionT
struct dataRefDefinitionT {
protected:
std::string dataName;
XPLMDataTypeID dataType = xplmType_Unknown;
XPLMGetDatai_f ifRead = NULL;
XPLMSetDatai_f ifWrite = NULL;
XPLMGetDataf_f ffRead = NULL;
XPLMSetDataf_f ffWrite = NULL;
XPLMGetDatab_f bfRead = NULL;
void* refCon = NULL;
bool bCfgFile = false;
bool bDebugLog = false; ///< log this setting in case of DEBUG logging?
public:
// constructor for xplmType_Int
dataRefDefinitionT (const char* name,
XPLMGetDatai_f _ifRead, XPLMSetDatai_f _ifWrite = NULL,
void* _refCon = NULL,
bool _bCfg = false,
bool _bDebugLog = false) :
dataName(name), dataType(xplmType_Int),
ifRead(_ifRead), ifWrite(_ifWrite),
refCon(_refCon), bCfgFile(_bCfg), bDebugLog(_bDebugLog) {}
// constructor for xplmType_Float
dataRefDefinitionT (const char* name,
XPLMGetDataf_f _ffRead, XPLMSetDataf_f _ffWrite = NULL,
void* _refCon = NULL,
bool _bCfg = false,
bool _bDebugLog = false) :
dataName(name), dataType(xplmType_Float),
ffRead(_ffRead), ffWrite(_ffWrite),
refCon(_refCon), bCfgFile(_bCfg), bDebugLog(_bDebugLog) {}
// constructor for xplmType_Data
dataRefDefinitionT (const char* name,
XPLMGetDatab_f _bfRead, XPLMSetDataf_f /*_bfWrite*/ = NULL,
void* _refCon = NULL,
bool _bCfg = false,
bool _bDebugLog = false) :
dataName(name), dataType(xplmType_Data),
bfRead(_bfRead),
refCon(_refCon), bCfgFile(_bCfg), bDebugLog(_bDebugLog) {}
// allows using the object in string context -> dataName
inline const std::string getDataNameStr() const { return dataName; }
inline const char* getDataName() const { return dataName.c_str(); }
inline operator const char* () const { return getDataName(); }
inline bool operator == (const dataRefDefinitionT& o) { return dataName == o.dataName; }
inline bool isWriteable () const { return (dataType == xplmType_Int) ? (ifWrite != NULL) :
(dataType == xplmType_Float) ? (ffWrite != NULL) : false; }
inline XPLMDataTypeID getDataTpe () const { return dataType; }
inline XPLMGetDatai_f getDatai_f () const { return ifRead; }
inline XPLMSetDatai_f setDatai_f () const { return ifWrite; }
inline XPLMGetDataf_f getDataf_f () const { return ffRead; }
inline XPLMSetDataf_f setDataf_f () const { return ffWrite; }
inline XPLMGetDatab_f getDatab_f () const { return bfRead; }
inline XPLMDataTypeID getDataType() const { return dataType; }
inline void* getRefCon() const { return refCon; }
inline void setRefCon (void* _refCon) { refCon = _refCon; }
inline bool isCfgFile() const { return bCfgFile; }
bool isDebugLogging() const { return bDebugLog; }
// get the actual current value (by calling the getData?_f function)
int getDatai () const;
float getDataf () const;
// set the value
void setData (int i);
void setData (float f);
void setData (const std::string& s);
// returns the string to be stored in a config file
std::string GetConfigString() const;
};
// which elements make up an a/c label?
struct LabelCfgTy {
unsigned
// static info
bIcaoType : 1, // default
bAnyAcId : 1, // default
bTranspCode : 1,
bReg : 1,
bIcaoOp : 1,
bCallSign : 1,
bFlightNo : 1,
bRoute : 1,
// dynamic info
bPhase : 1,
bHeading : 1,
bAlt : 1, // default
bHeightAGL : 1,
bSpeed : 1, // default
bVSI : 1;
// this is a bit ugly but avoids a wrapper union with an int
inline unsigned GetUInt() const { return *reinterpret_cast<const unsigned*>(this); }
inline void SetUInt(unsigned i) { *reinterpret_cast<unsigned*>(this) = i; }
inline bool operator != (const LabelCfgTy& o) const
{ return GetUInt() != o.GetUInt(); }
};
// when to show a/c labels?
struct LabelShowCfgTy {
unsigned
bExternal : 1, // external/outside views
bInternal : 1, // internal/cockpit views
bVR : 1, // VR views
bMap : 1; // Map icons
// this is a bit ugly but avoids a wrapper union with an int
inline unsigned GetUInt() const { return *reinterpret_cast<const unsigned*>(this); }
inline void SetUInt(unsigned i) { *reinterpret_cast<unsigned*>(this) = i; }
inline bool operator != (const LabelShowCfgTy& o) const
{ return GetUInt() != o.GetUInt(); }
};
/// represents a line in the [CSLPath] section of LiveTrafic.prg
struct CSLPathCfgTy {
public:
bool bEnabled = false; ///< enabled for auto-load on startup
protected:
int bPathExists = 0; ///< 3-values: -1 no, 0 not tested, 1 yes
std::string path; ///< actual path, can be relative to X-Plane system path
public:
CSLPathCfgTy () {}
CSLPathCfgTy (bool b, const std::string& p);
bool empty() const { return path.empty(); }
bool enabled() const { return bEnabled && !empty(); }
const std::string& getPath() const { return path; }
bool existsSave(); ///< tests path for existence, saves test result
bool exists() const; ///< tests path for existence
const std::string& operator= (const std::string& _p); ///< assign new path
bool operator== (const CSLPathCfgTy& o) const { return path == o.path; }
bool operator== (const std::string& s) const { return path == s; }
};
typedef std::vector<CSLPathCfgTy> vecCSLPaths;
public:
pluginStateTy pluginState = STATE_STOPPED;
#ifdef DEBUG
bool bSimVREntered = false; // for me to simulate some aspects of VR
double fdBufDebug = 0.0; // Due to debugging, the buffering period might extend a lot...
#endif
//MARK: DataRefs
protected:
XPLMDataRef adrXP[CNT_DATAREFS_XP]; ///< array of XP data refs to read from and shared dataRefs to provide
XPLMDataRef adrLT[CNT_DATAREFS_LT]; // array of data refs LiveTraffic provides
public:
XPLMCommandRef cmdXP[CNT_CMDREFS_XP] = { 0 }; // array of command refs
XPLMCommandRef cmdLT[CNT_CMDREFS_LT] = { 0 };
//MARK: Provided Data, i.e. global variables
protected:
std::thread::id xpThread; ///< id of X-Plane's thread (when it is OK to use XP API calls)
XPLMPluginID pluginID = 0;
logLevelTy iLogLevel = logWARN;
logLevelTy iMsgAreaLevel = logINFO;
#ifdef DEBUG
int logListLen = 500; ///< number of log message kept in storage to show in Info List Window
#else
int logListLen = 100; ///< number of log message kept in storage to show in Info List Window
#endif
int bShowingAircraft = false;
unsigned uDebugAcFilter = 0; // icao24 for a/c filter
int bDebugAcPos = false;// output debug info on position calc into log file?
int bDebugLogRawFd = false;// log raw flight data to LTRawFD.log
exportFDFormat eDebugExportFdFormat = EXP_FD_AITFC; ///< Which format to use when exporting flight data?
int bDebugExportFd = false;// export flight data to LTExportFD.csv
int bDebugExportUserAc = false;///< export user's aircraft data to LTExportFD.csv
float lastExportUserAc = 0.0f; ///< last time user's aircraft data has been written to export file
int bDebugExportNormTS = true; ///< normalize the timestamp when writing LTExportFD.csv, starting at 0 by the time exporting starts
int bDebugModelMatching = false;// output debug info on model matching in xplanemp?
std::string XPSystemPath;
std::string LTPluginPath; // path to plugin directory
std::string DirSeparator;
int bChannel[CNT_DR_CHANNELS]; // is channel enabled?
double chTsOffset = 0.0f; // offset of network time compared to system clock
int chTsOffsetCnt = 0; // how many offset reports contributed to the calculated average offset?
int iTodaysDayOfYear = 0;
time_t tStartThisYear = 0, tStartPrevYear = 0;
int lastCheckNewVer = 0; // when did we last check for updates? (hours since the epoch)
float lstLatRef = NAN; ///< last lat_ref, ie. known local coordinate system's reference point
float lstLonRef = NAN; ///< last lon_ref, ie. known local coordinate system's reference point
// generic config values
int bAutoStart = true; ///< shall display a/c right after startup?
int volMaster = 100; ///< Master Volume in Percent
int sndForceFmodInstance= DEF_SND_FMOD_INST; ///< Sound: Force using our own FMOD instance (instead of using XP's)
int bAIonRequest = false; ///< acquire multiplayer control for TCAS on request only, not automatically?
bool bAwaitingAIControl = false; ///< have in vain tried acquiring AI control and are waiting for callback now?
int bAINotOnGnd = false; ///< shall a/c on the ground be hidden from TCAS/AI?
// which elements make up an a/c label?
LabelCfgTy labelCfg = { 0,1,0,0,0,0,0,0, 0,0,0,0,0,0 };
LabelShowCfgTy labelShown = { 1, 1, 1, 1 }; ///< when to show? (default: always)
int labelMaxDist = 3; ///< [nm] max label distance
bool bLabelVisibilityCUtOff = true; ///< cut off labels at reported visibility?
bool bLabelColDynamic = false; // dynamic label color?
int labelColor = COLOR_YELLOW; ///< label color, by default yellow
int maxNumAc = DEF_MAX_NUM_AC; ///< how many aircraft to create at most?
int fdStdDistance = DEF_FD_STD_DISTANCE; ///< nm: miles to look for a/c around myself
int fdSnapTaxiDist = DEF_FD_SNAP_TAXI_DIST; ///< [m]: Snapping to taxi routes in a max distance of this many meter (0 -> off)
int fdRefreshIntvl = DEF_FD_REFRESH_INTVL; ///< how often to fetch new flight data
int fdLongRefrIntvl = DEF_FD_LONG_REFR_INTVL; ///< how often to fetch new flight data when flying high
int fdCurrRefrIntvl = DEF_FD_REFRESH_INTVL; ///< current value of how often to fetch new flight data
int fdBufPeriod = DEF_FD_BUF_PERIOD; ///< seconds to buffer before simulating aircraft
int fdReduceHeight = DEF_FD_REDUCE_HEIGHT; ///< [ft] reduce flight data usage when user aircraft is flying above this altitude
int netwTimeoutMax = DEF_MAX_NETW_TIMEOUT; ///< [s] of max network request timeout
int bLndLightsTaxi = false; // keep landing lights on while taxiing? (to be able to see the a/c as there is no taxi light functionality)
int hideBelowAGL = 0; // if positive: a/c visible only above this height AGL
int hideTaxiing = 0; // hide a/c while taxiing?
int hideParking = 0; ///< hide a/c parking at a startup-position (gate, ramp)?
int hideNearbyGnd = 0; // [m] hide a/c if closer than this to user's aircraft on the ground
int hideNearbyAir = 0; // [m] hide a/c if closer than this to user's aircraft in the air
int hideInReplay = false; ///< Shall no planes been shown while in Replay mode (to avoid collisions)?
int hideStaticTwr = true; ///< filter out TWR objects from the channels
int cpyObjFiles = 1; ///< copy `.obj` files for replacing dataRefs and textures
int contrailAltMin_ft = DEF_CONTR_ALT_MIN; ///< [ft] Auto Contrails: Minimum altitude
int contrailAltMax_ft = DEF_CONTR_ALT_MAX; ///< [ft] Auto Contrails: Maximum altitude
int contrailLifeTime = DEF_CONTR_LIFETIME; ///< [s] Contrail default time to live
bool contrailMulti = DEF_CONTR_MULTI; ///< Auto-create multiple or just a single contrail?
int remoteSupport = 0; ///< support XPMP2 Remote Client? (3-way: -1 off, 0 auto, 1 on)
int bUseExternalCamera = false; ///< Do not activate LiveTraffic's camera view when hitting the camera button (intended for a 3rd party camera plugin to activate instead based on reading livetraffic/camera/... dataRefs or using LTAPI)
// channel config options
int fscEnv = 0; ///< FSCharter: Which environment to connect to?
int ognUseRequRepl = 0; ///< OGN: Use Request/Reply instead of TCP receiver
int rtListenPort = 10747; // port opened for RT to connect
int rtTrafficPort = 49005; // UDP Port receiving traffic
int rtWeatherPort = 49004; // UDP Port receiving weather info
SimTimeCtrlTy rtSTC = STC_SIM_TIME_PLUS_BUFFER; ///< Which sim time to send to RealTraffic?
int rtManTOfs = 0; ///< manually configure time offset for requesting historic data
RTConnTypeTy rtConnType = RT_CONN_REQU_REPL; ///< Which type of connection to use for RealTraffic data
int ffListenPort = 63093; ///< UDP Port to listen to ForeFlight announcing itself, https://www.foreflight.com/connect/spec/
int ffSendPort = 49002; ///< UDP Port to send simulator data to ForeFlight, https://www.foreflight.com/support/network-gps/
int bffUserPlane = 1; // bool Send User plane data?
int bffTraffic = 1; // bool Send traffic data?
int ffSendTrfcIntvl = 3; // [s] interval to broadcast traffic info
vecCSLPaths vCSLPaths; // list of paths to search for CSL packages
std::string sDefaultAcIcaoType = CSL_DEFAULT_ICAO_TYPE;
std::string sDefaultCarIcaoType = CSL_CAR_ICAO_TYPE;
std::string sOpenSkyUser; ///< OpenSky Network user
std::string sOpenSkyPwd; ///< OpenSky Network password
std::string sADSBExAPIKey; ///< ADS-B Exchange API key
std::string sRTLicense; ///< RealTraffic License
std::string sFSCUser; ///< FSCharter login user
std::string sFSCPwd; ///< FSCharter login password
// live values
bool bReInitAll = false; // shall all a/c be re-initiaized (e.g. time jumped)?
int cntAc = 0; // number of a/c being displayed
std::string keyAc; // key (transpIcao) for a/c whose data is returned
const LTAircraft* pAc = nullptr; // ptr to that a/c
// Weather
float lastWeatherAttempt = 0.0f; ///< last time we _tried_ to update the weather
float lastWeatherUpd = 0.0f; ///< last time the weather was updated? (in XP's network time)
float lastWeatherHPA = HPA_STANDARD; ///< last barometric pressure received
positionTy lastWeatherPos; ///< last position for which weather was retrieved
std::string lastWeatherStationId; ///< last weather station we got weather from
std::string lastWeatherMETAR; ///< last full METAR string
//MARK: Debug helpers (public)
public:
std::string cslFixAcIcaoType; // set of fixed values to use for...
std::string cslFixOpIcao; // ...newly created aircraft for...
std::string cslFixLivery; // ...CSL model package testing
// MARK: Public members
public:
/// X-Plane version information
int xpVer = 0;
int xplmVer = 0;
std::string sXpVer;
/// once per Flarm a/c type: matching it to one or more ICAO types
std::array<std::vector<std::string>, 14> aFlarmToIcaoAcTy;
long OpenSkyRRemain = LONG_MAX; ///< OpenSky: Remaining number of requests per day
std::string OpenSkyRetryAt; ///< OpenSky: If limit is reached, when to retry? (local time as string)
long ADSBExRLimit = 0; // ADSBEx: Limit on RapidAPI
long ADSBExRRemain = 0; // ADSBEx: Remaining Requests on RapidAPI
// UI information
int UIopacity = DEF_UI_OPACITY; ///< [%] UI opacity
int UIFontScale = DEF_UI_FONT_SCALE; ///< [%] Font scale
// Message Box
WndRect MsgRect; ///< Message Box Window position
// Settings UI
WndRect SUIrect; ///< Settings UI Window position
int SUItransp = DEF_SUI_TRANSP; ///< Settings UI: transaprent background?
// A/C Info Window(s)
WndRect ACIrect; ///< A/C Info Window position
int ACIcollapsed = 0; ///< A/C Info Wnd collapsed sections status
// Info List Window (Status etc)
WndRect ILWrect; ///< Info List Window position
//MARK: Constructor
public:
DataRefs ( logLevelTy initLogLevel ); // Constructor doesn't do much
bool Init(); // Init DataRefs, return "OK?"
void InformDataRefEditors(); ///< tell DRE and DRT our dataRefs
void Stop(); // unregister what's needed
protected:
// call XPLMRegisterDataAccessor
bool RegisterDataAccessors();
bool RegisterCommands();
void* getVarAddr (dataRefsLT dr);
//MARK: DataRef access, partly cached for thread-safe access
protected:
static positionTy lastCamPos; ///< cached read camera position
float lastNetwTime = 0.0f; ///< cached network time
double lastSimTime = NAN; ///< cached simulated time
long long lastXPSimTime_ms = 0; ///< X-Plane's simulated time in milliseconds since the Unix epoch
bool lastReplay = true; ///< cached: is replay mode?
bool lastVREnabled = false; ///< cached info: VR enabled?
bool bUsingModernDriver = false; ///< modern driver in use?
positionTy lastUsersPlanePos; ///< cached user's plane position
int lastUsersAGL_ft = 0; ///< cached user's plane height above ground
double lastUsersTrueAirspeed = 0.0; ///< [m/s] cached user's plane's air speed
double lastUsersTrack = 0.0; ///< cacher user's plane's track
/// Wind Layer Data
struct WindLayerTy {
double alt_m = 0.0f; ///< [m] Wind Layer's altitude
double spd_msc = 0.0f; ///< [m/s] Wind Layer's speed
double dir_degt = 0.0f; ///< [degree] Wind Layer's direction
WindLayerTy (float a, float s, float d) :
alt_m(double(a)), spd_msc(double(s)), dir_degt(double(d)) {}
};
std::vector<WindLayerTy> lastWind; ///< the region's wind layers
public:
void ThisThreadIsXP() { xpThread = std::this_thread::get_id(); }
bool IsXPThread() const { return std::this_thread::get_id() == xpThread; }
float GetMiscNetwTime() const;
inline bool IsViewExternal() const { return XPLMGetDatai(adrXP[DR_VIEW_EXTERNAL]) != 0; }
inline XPViewTypes GetViewType () const { return (XPViewTypes)XPLMGetDatai(adrXP[DR_VIEW_TYPE]); }
inline bool UsingModernDriver () const { return bUsingModernDriver; }
inline bool IsVREnabled() const { return lastVREnabled; }
bool IsUsingSystemTime() const { return XPLMGetDatai(adrXP[DR_USE_SYSTEM_TIME]); }
int GetLocalDateDays() const { return XPLMGetDatai(adrXP[DR_LOCAL_DATE_DAYS]); }
float GetLocalTimeSec() const { return XPLMGetDataf(adrXP[DR_LOCAL_TIME_SEC]); }
float GetZuluTimeSec() const { return XPLMGetDataf(adrXP[DR_ZULU_TIME_SEC]); }
long long GetXPSimTime_ms() const { return lastXPSimTime_ms; }
void UpdateXPSimTime(); ///< Calculate X-Plane's current simulation time as Unix epoch time in milliseconds (Java timestamp)
std::string GetXPSimTimeStr() const; ///< Return a nicely formated time string with XP's simulated time in UTC
void SetViewType(XPViewTypes vt);
positionTy GetUsersPlanePos(double& trueAirspeed_m, double& track) const;
//MARK: DataRef provision by LiveTraffic
// Generic Get/Set callbacks
static int LTGetInt(void* p);
static float LTGetFloat(void* p);
static void LTSetBool(void* p, int i);
// Bulk data access to transfer a lot of a/c info to LTAPI
static int LTGetBulkAc (void* inRefcon, void * outValue,
int inStartIdx, int inNumAc);
protected:
/// Find dataRef definition based on the pointer to its member variable
static const dataRefDefinitionT* FindDRDef (void* p);
/// Save config(change) info to the log
static void LogCfgSetting (void* p, int val);
// a/c info
bool FetchPAc ();
public:
static void LTSetAcKey(void*p, int i);
static int LTGetAcInfoI(void* p);
static float LTGetAcInfoF(void* p);
void SetCameraAc(const LTAircraft* pCamAc); ///< sets the data of the shared datarefs to point to `ac` as the current aircraft under the camera
static void ClearCameraAc(void*); ///< shared dataRef callback: Whenever someone else writes to the shared dataRef we clear our a/c camera information
// seconds since epoch including fractionals
double GetSimTime() const { return lastSimTime; }
/// Current sim time as a human readable string, including 10th of seconds
std::string GetSimTimeString() const;
// livetraffic/sim/date and .../time
static int LTGetSimDateTime(void* p);
/// Are we in replay mode?
bool IsReplayMode() const { return lastReplay; }
// livetraffic/cfg/aircrafts_displayed: Aircraft Displayed
static void LTSetAircraftDisplayed(void* p, int i);
inline int AreAircraftDisplayed() const { return bShowingAircraft; }
void SetAircraftDisplayed ( int bEnable );
int ToggleAircraftDisplayed (); // returns new status (displayed?)
inline XPLMPluginID GetMyPluginId() const { return pluginID; }
// livetraffic/cfg/log_level: Log Level
static void LTSetLogLevel(void* p, int i);
void SetLogLevel ( int i );
void SetMsgAreaLevel ( int i );
inline logLevelTy GetLogLevel() { return iLogLevel; }
inline logLevelTy GetMsgAreaLevel() { return iMsgAreaLevel; }
/// Reinit data usage
void ForceDataReload ();
// general config values
static void LTSetCfgValue(void* p, int val);
bool SetCfgValue(void* p, int val);
void ResetAdvCfgToDefaults (); ///< Reset advanced config options to defaults
// generic config access (not as fast as specific access, but good for rare access)
static bool GetCfgBool (dataRefsLT dr);
static int GetCfgInt (dataRefsLT dr);
static float GetCfgFloat (dataRefsLT dr);
// specific access
inline bool GetAutoStart() const { return bAutoStart != 0; }
int GetVolumeMaster() const { return volMaster; }
bool ShallForceFmodInstance() const { return sndForceFmodInstance != 0; }
inline bool IsAIonRequest() const { return bAIonRequest != 0; }
bool IsAINotOnGnd() const { return bAINotOnGnd != 0; }
static int HaveAIUnderControl(void* =NULL) { return XPMPHasControlOfAIAircraft(); }
bool AwaitingAIControl() const { return bAwaitingAIControl; }
void SetAwaitingAIControl (bool _b) { bAwaitingAIControl = _b; }
inline LabelCfgTy GetLabelCfg() const { return labelCfg; }
inline LabelShowCfgTy GetLabelShowCfg() const { return labelShown; }
inline bool IsLabelColorDynamic() const { return bLabelColDynamic; }
inline int GetLabelColor() const { return labelColor; }
void GetLabelColor (float outColor[4]) const;
inline int GetMaxNumAc() const { return maxNumAc; }
void SetMaxNumAc(int n) { maxNumAc = n; }
inline int GetFdStdDistance_nm() const { return fdStdDistance; }
inline int GetFdStdDistance_m() const { return fdStdDistance * M_per_NM; }
inline int GetFdStdDistance_km() const { return fdStdDistance * M_per_NM / M_per_KM; }
inline int GetFdSnapTaxiDist_m() const { return fdSnapTaxiDist; }
inline int GetFdRefreshIntvl() const { return fdCurrRefrIntvl; }
inline int GetFdBufPeriod() const { return fdBufPeriod; }
inline int GetAcOutdatedIntvl() const { return 2 * GetFdBufPeriod(); }
inline int GetNetwTimeoutMax() const { return netwTimeoutMax; }
inline bool GetLndLightsTaxi() const { return bLndLightsTaxi != 0; }
inline int GetHideBelowAGL() const { return hideBelowAGL; }
inline bool GetHideTaxiing() const { return hideTaxiing != 0; }
inline bool GetHideParking() const { return hideParking != 0; }
inline int GetHideNearby(bool bGnd) const ///< return "hide nearby" config
{ return bGnd ? hideNearbyGnd : hideNearbyAir; }
inline bool GetHideInReplay() const { return hideInReplay; }
inline bool GetHideStaticTwr () const { return hideStaticTwr; }
bool WarnAutoHiding() const ///< any auto-hiding activated, that we should warn the user about?
{ return hideBelowAGL > 0 || hideTaxiing != 0 || hideParking != 0 ||
hideNearbyGnd > 0 || hideNearbyAir > 0 || hideInReplay; }
bool IsAutoHidingActive() const ///< any auto-hiding activated, including options no warning is issued about?
{ return hideStaticTwr || WarnAutoHiding(); }
bool ShallCpyObjFiles () const { return cpyObjFiles != 0; }
int GetContrailAltMin_ft () const { return contrailAltMin_ft; }
int GetContrailAltMax_ft () const { return contrailAltMax_ft; }
int GetContrailLifeTime () const { return contrailLifeTime; }
bool GetContrailMulti () const { return contrailMulti; }
int GetRemoteSupport () const { return remoteSupport; }
bool ShallUseExternalCamera () const { return bUseExternalCamera; }
bool NeedNewVerCheck () const;
void SetLastCheckedNewVerNow ();
const vecCSLPaths& GetCSLPaths() const { return vCSLPaths; }
vecCSLPaths& GetCSLPaths() { return vCSLPaths; }
bool LoadCSLPackage(const std::string& _path);
const std::string& GetDefaultAcIcaoType() const { return sDefaultAcIcaoType; }
const std::string& GetDefaultCarIcaoType() const { return sDefaultCarIcaoType; }
bool SetDefaultAcIcaoType(const std::string type);
bool SetDefaultCarIcaoType(const std::string type);
// livetraffic/channel/...
void SetChannelEnabled (dataRefsLT ch, bool bEnable);
inline bool IsChannelEnabled (dataRefsLT ch) const { return bChannel[ch - DR_CHANNEL_FIRST]; }
int CntChannelEnabled () const;
void GetOpenSkyCredentials (std::string& user, std::string& pwd)
{ user = sOpenSkyUser; pwd = sOpenSkyPwd; }
void SetOpenSkyUser (const std::string& user) { sOpenSkyUser = user; OpenSkyRRemain = LONG_MAX; OpenSkyRetryAt.clear(); }
void SetOpenSkyPwd (const std::string& pwd) { sOpenSkyPwd = pwd; OpenSkyRRemain = LONG_MAX; OpenSkyRetryAt.clear(); }
const std::string& GetADSBExAPIKey () const { return sADSBExAPIKey; }
void SetADSBExAPIKey (const std::string& apiKey) { sADSBExAPIKey = apiKey; }
bool SetRTTrafficPort (int port) { return SetCfgValue(&rtTrafficPort, port); }
SimTimeCtrlTy GetRTSTC () const { return rtSTC; } ///< RealTraffic simulator time control setting
int GetRTManTOfs () const { return rtManTOfs; } ///< [min] manually configured time offset in minutes
RTConnTypeTy GetRTConnType () const { return rtConnType; }
const std::string& GetRTLicense () const { return sRTLicense; }
void SetRTLicense (const std::string& license) { sRTLicense = license; }
size_t GetFSCEnv() const { return (size_t)fscEnv; }
void GetFSCharterCredentials (std::string& user, std::string& pwd)
{ user = sFSCUser; pwd = sFSCPwd; }
void SetFSCharterUser (const std::string& user) { sFSCUser = user; }
void SetFSCharterPwd (const std::string& pwd) { sFSCPwd = pwd; }
// timestamp offset network vs. system clock
inline void ChTsOffsetReset() { chTsOffset = 0.0f; chTsOffsetCnt = 0; }
inline double GetChTsOffset () const { return chTsOffset; }