From 46a0607b551b9eeaccb44f56e1797e494f651323 Mon Sep 17 00:00:00 2001 From: Kilian Hofmann Date: Sun, 11 Sep 2022 21:45:09 +0200 Subject: [PATCH] Fix Linux --- file/include/simdata/simDatabase.h | 10 ++++++---- file/include/simdata/simdataXP.h | 10 +++++----- file/simDatabase.cpp | 6 +++--- file/simdataXP.cpp | 24 +++++++++++------------- xplugin/main.cpp | 15 +++++---------- 5 files changed, 30 insertions(+), 35 deletions(-) diff --git a/file/include/simdata/simDatabase.h b/file/include/simdata/simDatabase.h index 78e2e3d..09a52e7 100644 --- a/file/include/simdata/simDatabase.h +++ b/file/include/simdata/simDatabase.h @@ -44,8 +44,8 @@ namespace file private: std::map< std::string, - std::pair, - std::vector>> + std::pair, + std::vector>> airports; void fromFile(); @@ -60,13 +60,15 @@ namespace file void toFile() const; inline std::size_t getCount() const { return this->airports.size(); } - inline const std::pair, const std::vector> + inline const std::pair, + const std::vector> operator[](std::string key) { try { return this->airports.at(key); } catch (std::out_of_range &ex) { - return std::pair, const std::vector>(); + return std::pair, + const std::vector>(); } } }; diff --git a/file/include/simdata/simdataXP.h b/file/include/simdata/simdataXP.h index 9df3bf8..4690f24 100644 --- a/file/include/simdata/simdataXP.h +++ b/file/include/simdata/simdataXP.h @@ -21,21 +21,21 @@ namespace file const std::string sceneryPack, const std::string logFile, std::map, std::vector>> + std::pair, std::vector>> &airports); void makeAirport( const std::string &kind, std::ifstream &infile, std::map, std::vector>> + std::pair, std::vector>> &airports, std::ofstream &logfile); - void makeGate15(std::vector &gates, + void makeGate15(std::vector &gates, const std::vector &fields); - void makeRunway(std::vector &runways, + void makeRunway(std::vector &runways, const std::vector &fields); - void makeGate1300(std::vector &gates, + void makeGate1300(std::vector &gates, const std::vector &fields); } // namespace simdata } // namespace file diff --git a/file/simDatabase.cpp b/file/simDatabase.cpp index a3bf95a..e87b781 100644 --- a/file/simDatabase.cpp +++ b/file/simDatabase.cpp @@ -96,11 +96,11 @@ namespace file write(out, airports.size()); // Airport for (const std::pair, std::vector>> + std::pair, std::vector>> &airport : airports) { std::string icao = airport.first; - const std::vector gates = airport.second.first; - const std::vector runways = airport.second.second; + const std::vector gates = airport.second.first; + const std::vector runways = airport.second.second; // ICAO writeString(out, icao); // Gates diff --git a/file/simdataXP.cpp b/file/simdataXP.cpp index 561eb7c..dfdd8d4 100644 --- a/file/simdataXP.cpp +++ b/file/simdataXP.cpp @@ -10,8 +10,7 @@ namespace file const std::string defaultFile, const std::string sceneryPack, const std::string logFile, - std::map, std::vector>> + std::map, std::vector>> &airports) { std::ifstream base(defaultFile); @@ -72,15 +71,14 @@ namespace file void makeAirport( const std::string &kind, std::ifstream &infile, - std::map, std::vector>> + std::map, std::vector>> &airports, std::ofstream &logfile) { std::string line; std::string *currentIcao = nullptr; - std::vector tmpGates; - std::vector tmpRunways; + std::vector tmpGates; + std::vector tmpRunways; int apCount = 0; int validCount = 0; @@ -106,8 +104,8 @@ namespace file logfile << "\t " << *currentIcao << " had no gates or runways" << std::endl; } - tmpGates = std::vector(); - tmpRunways = std::vector(); + tmpGates = std::vector(); + tmpRunways = std::vector(); currentIcao = new std::string(fields[4]); apCount += 1; logfile << "\t<" << kind << "> " << line << std::endl; @@ -126,8 +124,8 @@ namespace file logfile << "\t " << *currentIcao << " had no gates or runways" << std::endl; } - tmpGates = std::vector(); - tmpRunways = std::vector(); + tmpGates = std::vector(); + tmpRunways = std::vector(); currentIcao = nullptr; logfile << "\t<" << kind << " SKIPPED> " << line << std::endl; } else if (currentIcao != nullptr && fields[0] == "100") { @@ -148,7 +146,7 @@ namespace file << validCount << " are valid" << std::endl; } - void makeGate15(std::vector &gates, + void makeGate15(std::vector &gates, const std::vector &fields) { std::string gateName; @@ -163,7 +161,7 @@ namespace file gates.emplace_back(gateName, pt, 40); } - void makeRunway(std::vector &runways, + void makeRunway(std::vector &runways, const std::vector &fields) { runways.emplace_back(fields[8], @@ -180,7 +178,7 @@ namespace file std::stod(fields[1])); } - void makeGate1300(std::vector &gates, + void makeGate1300(std::vector &gates, const std::vector &fields) { std::string gateName; diff --git a/xplugin/main.cpp b/xplugin/main.cpp index d3b8398..0a4e58c 100644 --- a/xplugin/main.cpp +++ b/xplugin/main.cpp @@ -114,17 +114,12 @@ PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc) configuration = std::make_unique(); toLog("Config loaded"); - try { - connector = std::make_unique( - "ss://ws.hofmannnet.myhome-server.de:8000", - configuration->getUser(), - toLog); - } catch (const std::invalid_argument &e) { - toLog("SOCK"); - toLog(e.what()); - return 0; - } + connector = std::make_unique( + "wss://ws.hofmannnet.myhome-server.de:8000", + configuration->getUser(), + toLog); toLog("WebSocket started"); + char hash[2 * MD5LEN + 1] = ""; if (germanairlinesva::util::generateMD5(XPLANE_CUSTOM_SCENERY, hash, toLog) == 0) {