Skip to content

Commit

Permalink
Merge pull request #236 from TwinFan/Next
Browse files Browse the repository at this point in the history
v3.0.0
  • Loading branch information
TwinFan authored Jun 14, 2022
2 parents d641095 + f8dac0f commit 1cd3a2d
Show file tree
Hide file tree
Showing 50 changed files with 876 additions and 235 deletions.
14 changes: 12 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@

cmake_minimum_required(VERSION 3.16)
project(LiveTraffic
VERSION 2.60
VERSION 3.0.0
DESCRIPTION "LiveTraffic X-Plane plugin")

# Provide compile macros from the above project version definition
add_compile_definitions(
LIVETRAFFIC_VERSION_BETA=0
LIVETRAFFIC_VER_MAJOR=${PROJECT_VERSION_MAJOR}
LIVETRAFFIC_VER_MINOR=${PROJECT_VERSION_MINOR}
LIVETRAFFIC_VER_PATCH=${PROJECT_VERSION_PATCH}
)

################################################################################
# Target Systems
################################################################################
Expand Down Expand Up @@ -57,7 +65,6 @@ else()
add_compile_options(-fvisibility=hidden)
endif()


# Debug vs Release build
if(CMAKE_BUILD_TYPE MATCHES "Debug")
add_compile_definitions(DEBUG=1)
Expand Down Expand Up @@ -180,6 +187,9 @@ set(Source_Files
Lib/ImgWindow/ImgFontAtlas.cpp
Lib/ImgWindow/ImgWindow.cpp
)
if (WIN32)
list(APPEND Source_Files "LiveTraffic.rc")
endif()
source_group("Source Files" FILES ${Source_Files})

set(ALL_FILES ${Header_Files} ${Source_Files})
Expand Down
Binary file removed Data/RealTraffic/RTdev1.4.pdf
Binary file not shown.
Binary file added Data/RealTraffic/RTdev2.0.pdf
Binary file not shown.
2 changes: 2 additions & 0 deletions Data/RealTraffic/startRT
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
java -jar /Applications/RealTrafficLauncher.app/Contents/Resources/Jars/RealTrafficLauncher.jar
1 change: 1 addition & 0 deletions Include/ACTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ enum ACTColumnsTy {
ACT_COL_UPDOWN, ///< up/down arrows
ACT_COL_VSI, ///< vertical speed
ACT_COL_SPEED, ///< speed in knots
ACT_COL_TRACK, ///< track
ACT_COL_HEADING, ///< heading
ACT_COL_PITCH, ///< pitch
ACT_COL_ROLL, ///< roll
Expand Down
18 changes: 8 additions & 10 deletions Include/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
//
// MARK: Version Information (CHANGE VERSION HERE)
//
constexpr float VERSION_NR = 2.61f;
constexpr bool VERSION_BETA = false;
extern float verXPlaneOrg; // version on X-Plane.org
extern int verDateXPlaneOrg; // and its date

/// Verson number combined as a single unsigned, like 3.2.1 = 30201
constexpr unsigned LT_VER_NO = 10000 * LIVETRAFFIC_VER_MAJOR + 100 * LIVETRAFFIC_VER_MINOR + LIVETRAFFIC_VER_PATCH;
extern unsigned verXPlaneOrg; ///< version on X-Plane.org

//MARK: Window Position
#define WIN_WIDTH 400 // window width
Expand Down Expand Up @@ -74,7 +74,7 @@ constexpr double FLIGHT_LOOP_INTVL = -5.0; // call ourselves every 5 frames
constexpr double AC_MAINT_INTVL = 2.0; // seconds (calling a/c maintenance periodically)
constexpr double TIME_REQU_POS = 0.5; // seconds before reaching current 'to' position we request calculation of next position
constexpr double SIMILAR_TS_INTVL = 3; // seconds: Less than that difference and position-timestamps are considered "similar" -> positions are merged rather than added additionally
constexpr double SIMILAR_POS_DIST = 3; // [m] if distance between positions less than this then favor heading from flight data over vector between positions
constexpr double SIMILAR_POS_DIST = 7; // [m] if distance between positions less than this then favor heading from flight data over vector between positions
constexpr double FD_GND_AGL = 10; // [m] consider pos 'ON GRND' if this close to YProbe
constexpr double FD_GND_AGL_EXT = 20; // [m] consider pos 'ON GRND' if this close to YProbe - extended, e.g. for RealTraffic
constexpr double PROBE_HEIGHT_LIM[] = {5000,1000,500,-999999}; // if height AGL is more than ... feet
Expand Down Expand Up @@ -150,9 +150,6 @@ constexpr int LT_NEW_VER_CHECK_TIME = 48; // [h] between two checks of a new
//MARK: Text Constants
#define LIVE_TRAFFIC "LiveTraffic"
#define LIVE_TRAFFIC_XPMP2 " LT" ///< short form for logging by XPMP2, so that log entries are aligned
#define LT_CFG_VER_NM_CONV "1.0" // version of config file format, from which to convert distances from km to nm
#define LT_CFG_VER_DEL_IMGUI "1.1" // cfg file version, for which we need to remove imgui config file (as we added a column into the aircraft list)
#define LT_CFG_VERSION "2.2" // current version of config file format
#define LT_FM_VERSION "2.2" // expected version of flight model file format
#define PLUGIN_SIGNATURE "TwinFan.plugin.LiveTraffic"
#define PLUGIN_DESCRIPTION "Create Multiplayer Aircraft based on live traffic."
Expand All @@ -164,7 +161,8 @@ constexpr const char* REMOTE_SIGNATURE = "TwinFan.plugin.XPMP2.Remote";
#define MSG_WELCOME "LiveTraffic %s successfully loaded!"
#define MSG_REINIT "LiveTraffic is re-initializing itself"
#define MSG_DISABLE_MYSELF "LiveTraffic disables itself due to unhandable exceptions"
#define MSG_LT_NEW_VER_AVAIL "The new version %01.2f of LiveTraffic is available at X-Plane.org!"
#define MSG_LT_NEW_VER_AVAIL "The new version %s of LiveTraffic is available at X-Plane.org!"
#define MSG_LT_UPDATED "LiveTraffic has been updated to version %s"
#define MSG_TIMESTAMPS "Current System time is %sZ, current simulated time is %s"
#define MSG_AI_LOAD_ACF "Changing AI control: X-Plane is now loading AI Aircraft models..."
#define MSG_REQUESTING_LIVE_FD "Requesting live flight data online..."
Expand Down Expand Up @@ -234,7 +232,7 @@ constexpr const char* REMOTE_SIGNATURE = "TwinFan.plugin.XPMP2.Remote";
#define MENU_HELP_AC_INFO_WND "A/C Info Window"
#define MENU_HELP_SETTINGS "Settings"
#define MENU_HELP_INSTALL_CSL "Installaton of CSL Models"
#define MENU_NEWVER "New Version %01.2f available!"
#define MENU_NEWVER "New Version %s available!"
#ifdef DEBUG
#define MENU_RELOAD_PLUGINS "Reload all Plugins (Caution!)"
#define MENU_REMOVE_ALL_BUT "Remove all but selected a/c"
Expand Down
24 changes: 22 additions & 2 deletions Include/DataRefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ enum dataRefsXP {
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?
Expand All @@ -226,6 +227,8 @@ enum dataRefsXP {
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_WIND_DIR, ///< sim/weather/wind_direction_degt float n [0-359) The effective direction of the wind at the plane's location.
DR_WIND_SPEED, ///< sim/weather/wind_speed_kt float n msc >= 0 The effective speed of the wind at the plane's location. WARNING: this dataref is in meters/second - the dataref NAME has a bug.
DR_VR_ENABLED, // VR stuff
CNT_DATAREFS_XP // always last, number of elements
};
Expand Down Expand Up @@ -368,6 +371,8 @@ enum dataRefsLT {
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_REMOTE_SUPPORT,
DR_CFG_EXTERNAL_CAMERA,
Expand Down Expand Up @@ -645,9 +650,11 @@ class DataRefs
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 remoteSupport = 0; ///< support XPMP2 Remote Client? (3-way: -1 off, 0 auto, 1 on)
bool 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)
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?
Expand Down Expand Up @@ -731,11 +738,13 @@ class DataRefs
static positionTy lastCamPos; ///< cached read camera position
float lastNetwTime = 0.0f; ///< cached network time
double lastSimTime = NAN; ///< cached simulated time
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
double lastUsersTrueAirspeed = 0.0; ///< [m/s] cached user's plane's air speed
double lastUsersTrack = 0.0; ///< cacher user's plane's track
vectorTy lastWind; ///< wind at user's plane's location
public:
void ThisThreadIsXP() { xpThread = std::this_thread::get_id(); }
bool IsXPThread() const { return std::this_thread::get_id() == xpThread; }
Expand Down Expand Up @@ -786,6 +795,9 @@ class DataRefs
static void LTSetSimDateTime(void* p, int i);
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; }
Expand Down Expand Up @@ -843,9 +855,11 @@ class DataRefs
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; }
inline bool IsAutoHidingActive() const ///< any auto-hiding activated?
{ return hideBelowAGL > 0 || hideTaxiing != 0 || hideParking != 0 ||
hideNearbyGnd > 0 || hideNearbyAir > 0; }
hideNearbyGnd > 0 || hideNearbyAir > 0 || hideInReplay; }
bool ShallCpyObjFiles () const { return cpyObjFiles != 0; }
int GetRemoteSupport () const { return remoteSupport; }
bool ShallUseExternalCamera () const { return bUseExternalCamera; }
Expand All @@ -869,6 +883,8 @@ class DataRefs
std::string GetADSBExAPIKey () const { return sADSBExAPIKey; }
void SetADSBExAPIKey (std::string apiKey) { sADSBExAPIKey = apiKey; }

bool SetRTTrafficPort (int port) { return SetCfgValue(&rtTrafficPort, port); }

size_t GetFSCEnv() const { return (size_t)fscEnv; }
void GetFSCharterCredentials (std::string& user, std::string& pwd)
{ user = sFSCUser; pwd = sFSCPwd; }
Expand Down Expand Up @@ -933,6 +949,7 @@ class DataRefs
protected:
void UpdateUsersPlanePos (); ///< fetches user's plane position
static void UpdateViewPos(); ///< read and cache camera position
void UpdateSimWind (); ///< Update local (in sim!) wind at user's plane


//MARK: Processed values
Expand All @@ -959,6 +976,9 @@ class DataRefs
double WeatherPressureAlt_ft (double geoAlt_ft) { return geoAlt_ft - altPressCorr_ft; }
/// Thread-safely gets current weather info
void GetWeather (float& hPa, std::string& stationId, std::string& METAR);

/// Local (in sim!) wind at user's plane
const vectorTy& GetSimWind () const { return lastWind; }
};

extern DataRefs::dataRefDefinitionT DATA_REFS_LT[CNT_DATAREFS_LT];
Expand Down
17 changes: 4 additions & 13 deletions Include/LTADSBEx.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,24 @@
#define ADSBEX_TRT "trt"
#define ADSBEX_RADAR_CODE "sqk" // Dynamic data
#define ADSBEX_CALL "call"
// #define ADSBEX_C_MSG "CMsgs"
#define ADSBEX_LAT "lat"
#define ADSBEX_LON "lon"
#define ADSBEX_ELEVATION "galt" // geometric altitude
#define ADSBEX_ALT "alt" // barometric altitude
#define ADSBEX_HEADING "trak"
#define ADSBEX_GND "gnd"
// #define ADSBEX_IN_HG "InHg"
#define ADSBEX_POS_TIME "postime"
// #define ADSBEX_POS_STALE "PosStale"
// #define ADSBEX_BRNG "Brng"
// #define ADSBEX_DST "Dst"
#define ADSBEX_SPD "spd"
#define ADSBEX_VSI "vsi"
#define ADSBEX_REG "reg"
#define ADSBEX_COUNTRY "cou"
#define ADSBEX_AC_TYPE_ICAO "type"
// #define ADSBEX_MAN "Man"
// #define ADSBEX_MDL "Mdl"
// #define ADSBEX_YEAR "Year"
#define ADSBEX_MIL "mil"
// #define ADSBEX_OP "Op"
#define ADSBEX_OP_ICAO "opicao"
// #define ADSBEX_ENG_TYPE "EngType"
// #define ADSBEX_ENG_MOUNT "EngMount"
// #define ADSBEX_ORIGIN "From"
// #define ADSBEX_DESTINATION "To"
#define ADSBEX_ORIGIN "from"
#define ADSBEX_DESTINATION "to"

#define ADSBEX_TYPE_GND "-GND"

// still used in historic data code, unsure if supported:
#define ADSBEX_RCVR "Rcvr"
Expand Down
14 changes: 11 additions & 3 deletions Include/LTAircraft.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ struct MovingParam
inline double dist () const { return valDist; }
inline double fromTS () const { return timeFrom; }
inline double toTS () const { return timeTo; }
double percDone () const; ///< percent done of move, returns 1.0 if not in motion
};

// mimics acceleration / deceleration
Expand Down Expand Up @@ -256,9 +257,11 @@ class LTAircraft : public XPMP2::Aircraft
public:
static bool ReadFlightModelFile ();
/// @brief Returns a model based on pAc's type, fd.statData's type or by trying to derive a model from statData.mdlName
/// @param fd Flight Data of the plane in question
/// @param fd Flight Data of the plane in question, might be updated with found model
/// @param bForceSearch (optional) If `true` then no cached values are returned but a full search in the model rules is done
/// @param[out] pIcaoType (optional) receives determined ICAO type, empty if none could be determined
static const FlightModel& FindFlightModel (const LTFlightData& fd,
static const FlightModel& FindFlightModel (LTFlightData& fd,
bool bForceSearch = false,
const std::string** pIcaoType = nullptr);
static const FlightModel* GetFlightModel (const std::string& modelName);
/// Tests if the given call sign matches typical call signs of ground vehicles
Expand Down Expand Up @@ -302,6 +305,7 @@ class LTAircraft : public XPMP2::Aircraft
AccelParam speed; // current speed [m/s] and acceleration control
BezierCurve turn; ///< position, heading, roll while flying a turn
MovingParam heading; ///< heading movement if not using a Bezier curve
MovingParam corrAngle; ///< correction angle for cross wind
MovingParam gear;
MovingParam flaps;
MovingParam pitch;
Expand Down Expand Up @@ -361,7 +365,7 @@ class LTAircraft : public XPMP2::Aircraft
std::string GetFlightPhaseRwyString() const; ///< GetFlightPhaseString() plus rwy id in case of approach
inline bool IsOnGrnd() const { return bOnGrnd; }
bool IsOnRwy() const; ///< is the aircraft on a rwy (on ground and at least on pos on rwy)
inline double GetHeading() const { return ppos.heading(); }
inline double GetHeading() const { return ppos.heading() + corrAngle.is(); }
inline double GetTrack() const { return vec.angle; }
inline double GetFlapsPos() const { return flaps.is(); }
inline double GetGearPos() const { return gear.is(); }
Expand All @@ -372,6 +376,7 @@ class LTAircraft : public XPMP2::Aircraft
inline double GetVSI_m_s() const { return vsi * Ms_per_FTm; } // m/s
inline double GetPitch() const { return ppos.pitch(); }
inline double GetRoll() const { return ppos.roll(); }
float GetLift() const override; ///< Lift produced for wake system, typically mass * 9.81, but blends in during rotate and blends out while landing
inline double GetAlt_ft() const { return ppos.alt_ft(); }
inline double GetAlt_m() const { return ppos.alt_m(); }
inline double GetTerrainAlt_ft() const { return terrainAlt_m / M_per_FT; } ///< terrain alt converted to ft
Expand Down Expand Up @@ -406,6 +411,9 @@ class LTAircraft : public XPMP2::Aircraft
void CalcFlightModel (const positionTy& from, const positionTy& to);
/// determine roll, based on a previous and a current heading
void CalcRoll (double _prevHeading);
/// determine correction angle
void CalcCorrAngle ();
/// determines terrain altitude via XPLM's Y Probe
bool YProbe ();
// determines if now visible
bool CalcVisible ();
Expand Down
2 changes: 1 addition & 1 deletion Include/LTFSCharter.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

//MARK: FSCharter Constants
#define FSC_CHECK_NAME "FSCharter Flight Board"
#define FSC_CHECK_URL "https://fscharter.net/flight_board"
#define FSC_CHECK_URL "https://fscharter.net/flight-board"
#define FSC_CHECK_POPUP "See who's flying in FSCharter just now"

#define FSC_NAME "FSCharter"
Expand Down
3 changes: 3 additions & 0 deletions Include/LTFlightData.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ class LTFlightData
static std::ofstream fileExport;
static double fileExportTsBase; ///< when normalizing timestamps this is the base

/// Cache for flight model in use, actually of type LTAircraft::FlightModel, but we can't forward-declare it here
const void* pMdl = nullptr;

protected:
static std::string fileExportName; ///< current export file's name

Expand Down
Loading

0 comments on commit 1cd3a2d

Please sign in to comment.