Skip to content

Commit

Permalink
Merge pull request #265 from TwinFan/Next
Browse files Browse the repository at this point in the history
v3.5.1 Hotfix OpenSky et al.
  • Loading branch information
TwinFan authored Feb 17, 2024
2 parents 4d8a05b + 4e2a94a commit 50807fd
Show file tree
Hide file tree
Showing 20 changed files with 1,160 additions and 959 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ on:
# Let's set all project specific definitions globally
env:
PRJ_NAME: LiveTraffic # The plugin's name, expected to be the .xpl file's name and used as the plugin folder name
version_beta: ${{ github.ref != 'refs/heads/master' && '1' || '0' }} # On non-master branches we build BETA versions
# On master branches or when explicitely tagged we build prod versions, otherwise BETA
version_beta: ${{ (github.ref != 'refs/heads/master' && github.ref_type != 'tag') && '1' || '0' }}

jobs:
#####################################
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ else()
endif()

project(LiveTraffic
VERSION 3.5.0
VERSION 3.5.1
DESCRIPTION "LiveTraffic X-Plane plugin")

# Building a Beta version can be demanded via ENV variable 'version_beta' being set to 1
Expand Down
Binary file added Data/RealTraffic/RT_API.sjson/729379088.21102
Binary file not shown.
Binary file added Data/RealTraffic/RT_API.sjson/729379133.463946
Binary file not shown.
Binary file modified Data/RealTraffic/RT_API.sjson/data
Binary file not shown.
Binary file modified Data/RealTraffic/RT_API.sjson/metaData
Binary file not shown.
6 changes: 6 additions & 0 deletions Include/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ constexpr const char* REMOTE_SIGNATURE = "TwinFan.plugin.XPMP2.Remote";
#define MENU_HAVE_TCAS "TCAS controlled"
#define MENU_HAVE_TCAS_REQUSTD "TCAS controlled (requested)"
#define MENU_TOGGLE_LABELS "Labels shown"
#define MENU_TOGGLE_AC_AHEAD "Hide Aircraft ahead"
#define MENU_SETTINGS_UI "Settings..."
#define MENU_HELP "Help"
#define MENU_HELP_DOCUMENTATION "Documentation"
Expand All @@ -237,6 +238,8 @@ 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_HELP_SUPPORT_FORUM "Support Forum"
#define MENU_HELP_SUPPORT_HOWTO "Support HowTo"
#define MENU_NEWVER "New Version %s available!"
#ifdef DEBUG
#define MENU_RELOAD_PLUGINS "Reload all Plugins (Caution!)"
Expand Down Expand Up @@ -270,6 +273,9 @@ constexpr const char* REMOTE_SIGNATURE = "TwinFan.plugin.XPMP2.Remote";
#define HELP_SET_CSL "setup/configuration/settings-csl"
#define HELP_SET_DEBUG "setup/configuration/settings-debug"

#define URL_SUPPORT_FORUM "https://forums.x-plane.org/index.php?/forums/forum/457-livetraffic-support/"
#define URL_SUPPORT_HOWTO "https://forums.x-plane.org/index.php?/forums/topic/174691-support"

//MARK: File Paths
// these are under the plugins directory
#define PATH_FLIGHT_MODELS "Resources/FlightModels.prf"
Expand Down
7 changes: 4 additions & 3 deletions Include/DataRefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ enum cmdRefsLT {
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
};
Expand Down Expand Up @@ -1036,9 +1037,9 @@ class DataRefs
int DecNumAc();

// Get XP System Path
inline std::string GetXPSystemPath() const { return XPSystemPath; }
inline std::string GetLTPluginPath() const { return LTPluginPath; }
inline std::string GetDirSeparator() const { return DirSeparator; }
const std::string& GetXPSystemPath() const { return XPSystemPath; }
const std::string& GetLTPluginPath() const { return LTPluginPath; }
const std::string& GetDirSeparator() const { return DirSeparator; }

// Load/save config file (basically a subset of LT dataRefs)
bool LoadConfigFile();
Expand Down
1 change: 1 addition & 0 deletions Include/LTOpenSky.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ constexpr size_t OPSKY_MD_TEXT_VEHICLE_LEN = 20; ///< length after which cate

#define OPSKY_MD_DB_NAME "OpenSky Masterdata File"
#define OPSKY_MD_DB_URL "https://opensky-network.org/datasets/metadata/"
#define OPSKY_MD_DB_FILE_BEGIN "aircraft-database-complete-"
#define OPSKY_MD_DB_FILE "aircraft-database-complete-%04d-%02d.csv"

#define OPSKY_ROUTE_URL "https://opensky-network.org/api/routes?callsign="
Expand Down
8 changes: 5 additions & 3 deletions Include/LTRealTraffic.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ constexpr double RT_VSI_AIRBORNE = 80.0; ///< if VSI is more than this then w
constexpr long RT_DRCT_DEFAULT_WAIT = 8000L; ///< [ms] Default wait time between traffic requests
constexpr std::chrono::seconds RT_DRCT_ERR_WAIT = std::chrono::seconds(5); ///< standard wait between errors
constexpr std::chrono::minutes RT_DRCT_WX_WAIT = std::chrono::minutes(10); ///< How often to update weather?
constexpr std::chrono::seconds RT_DRCT_WX_ERR_WAIT = std::chrono::seconds(60); ///< How long to wait after receiving an weather error?
constexpr long RT_DRCT_WX_DIST = 10L * M_per_NM; ///< Distance for which weather is considered valid, greater than that and we re-request
constexpr int RT_DRCT_MAX_WX_ERR = 10; ///< Max number of consecutive errors during weather requests we wait for...before not asking for weather any longer
constexpr int RT_DRCT_MAX_WX_ERR = 5; ///< Max number of consecutive errors during initial weather requests we wait for...before not asking for weather any longer

/// Fields in a response of a direct connection's request
enum RT_DIRECT_FIELDS_TY {
Expand Down Expand Up @@ -265,12 +266,13 @@ class RealTrafficConnection : public LTFlightDataChannel
/// Weather data
struct WxTy {
double QNH = NAN; ///< baro pressure
std::chrono::steady_clock::time_point time; ///< time when RealTraffic weather was received
std::chrono::steady_clock::time_point next; ///< next time to request RealTraffic weather
positionTy pos; ///< viewer position for which we received Realtraffic weather
long tOff = 0; ///< time offset for which we requested weather
int nErr = 0; ///< How many errors did we have during weather requests?

WxTy& operator = (const CurrTy& o); ///< fill from `current` data
/// Set all relevant values
void set (double qnh, const CurrTy& o, bool bResetErr = true);
} rtWx; ///< Data with which latest weather was requested
/// How many flights does RealTraffic have in total?
long lTotalFlights = -1;
Expand Down
4 changes: 4 additions & 0 deletions Include/LiveTraffic.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ bool RemoteFileDownload (const std::string& url, const std::string& path);
std::string& str_toupper(std::string& s);
/// return a std::string copy converted to uppercase
std::string str_toupper_c(const std::string& s);
/// Case-insensitive equal
bool striequal (const std::string& a, const std::string& b);
/// Case-insensitive begins with
bool stribeginwith (const std::string& s, const std::string& begin);
// are all chars alphanumeric?
bool str_isalnum(const std::string& s);
// limits text to m characters, replacing the last ones with ... if too long
Expand Down
4 changes: 2 additions & 2 deletions LiveTraffic.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@
LIVETRAFFIC_VERSION_BETA = 0;
LIVETRAFFIC_VER_MAJOR = 3;
LIVETRAFFIC_VER_MINOR = 5;
LIVETRAFFIC_VER_PATCH = 0;
LIVETRAFFIC_VER_PATCH = 1;
LLVM_LTO = NO;
MACH_O_TYPE = mh_dylib;
MACOSX_DEPLOYMENT_TARGET = 10.15;
Expand Down Expand Up @@ -896,7 +896,7 @@
LIVETRAFFIC_VERSION_BETA = 0;
LIVETRAFFIC_VER_MAJOR = 3;
LIVETRAFFIC_VER_MINOR = 5;
LIVETRAFFIC_VER_PATCH = 0;
LIVETRAFFIC_VER_PATCH = 1;
LLVM_LTO = YES;
MACH_O_TYPE = mh_dylib;
MACOSX_DEPLOYMENT_TARGET = 10.15;
Expand Down
1 change: 1 addition & 0 deletions Src/DataRefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ struct cmdRefDescrTy {
{"LiveTraffic/Aircrafts/Display", "Starts/Stops display of live aircraft"},
{"LiveTraffic/Aircrafts/TCAS_Control", "TCAS Control toggle: Tries to take control over AI aircraft, or release it"},
{"LiveTraffic/Aircrafts/Toggle_Labels", "Toggle display of labels in current view"},
{"LiveTraffic/Aircrafts/Toggle_Ahead", "Toggle visibility of aircraft ahead"},
{"LiveTraffic/Settings/Open", "Opens/Closes the Settings window"},
};

Expand Down
4 changes: 4 additions & 0 deletions Src/LTChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,8 +887,12 @@ void LTFlightDataDisable()

void LTFlightDataStop()
{
/// @see https://github.com/Homebrew/homebrew-core/issues/158759#issuecomment-1874091015
/// To be able to reload plugins we don't properly call global cleanup
#if not APL
// cleanup global CURL stuff
curl_global_cleanup();
#endif
}

//
Expand Down
19 changes: 19 additions & 0 deletions Src/LTMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,25 @@ std::string str_toupper_c(const std::string& s)
return c;
}

// Case-insensitive equal
/// @see https://stackoverflow.com/a/4119881
bool striequal (const std::string& a, const std::string& b)
{
return std::equal(a.begin(), a.end(), b.begin(), b.end(),
[](unsigned char x, unsigned char y)
{ return std::tolower(x) == std::tolower(y); });
}

// Case-insensitive begins with
bool stribeginwith (const std::string& s, const std::string& begin)
{
if (begin.size() > s.size()) return false;
return std::equal(begin.begin(), begin.end(), s.begin(),
[](unsigned char x, unsigned char y)
{ return std::tolower(x) == std::tolower(y); });
}


bool str_isalnum(const std::string& s)
{
return std::all_of(s.cbegin(), s.cend(), [](unsigned char c){return isalnum(c);});
Expand Down
Loading

0 comments on commit 50807fd

Please sign in to comment.