Skip to content

Commit

Permalink
Fix weather in XP11
Browse files Browse the repository at this point in the history
  • Loading branch information
fpw committed May 7, 2023
1 parent ee2d74e commit aa5892e
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.9)
project(AviTab VERSION 0.6.1 DESCRIPTION "AviTab X-Plane plugin")
project(AviTab VERSION 0.6.2 DESCRIPTION "AviTab X-Plane plugin")

if (NOT "$ENV{NAVIGRAPH_SECRET}" STREQUAL "")
set(NAVIGRAPH_SECRET "$ENV{NAVIGRAPH_SECRET}" CACHE INTERNAL "Copied from environment variable")
Expand Down
1 change: 1 addition & 0 deletions lib/cairo
Submodule cairo added at aee96d
1 change: 1 addition & 0 deletions lib/litehtml
Submodule litehtml added at f06d13
1 change: 1 addition & 0 deletions lib/pixman
Submodule pixman added at 9b49f4
11 changes: 4 additions & 7 deletions src/environment/xplane/XPlaneEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ XPlaneEnvironment::XPlaneEnvironment() {
XPLMHostApplicationID hostId;
XPLMGetVersions(&xpVersion, &xplmVersion, &hostId);
if (xplmVersion >= 400) {
isXP12 = true;
getMetar = (GetMetarPtr) XPLMFindSymbol("XPLMGetMETARForAirport");
} else {
getMetar = nullptr;
}

updatePlaneCount();
Expand Down Expand Up @@ -363,18 +364,14 @@ double XPlaneEnvironment::getMagneticVariation(double lat, double lon) {

std::string XPlaneEnvironment::getMETARForAirport(const std::string &icao) {
std::string metar, timestamp;
if (isXP12) {
if (getMetar) {
std::promise<std::string> dataPromise;
auto futureData = dataPromise.get_future();

auto startAt = std::chrono::steady_clock::now();
runInEnvironment([this, icao, &dataPromise] () {
XPLMFixedString150_t buf;
if (getMetar) {
getMetar(icao.c_str(), &buf);
} else {
strcpy(buf.buffer, "XPLM Error");
}
getMetar(icao.c_str(), &buf);
dataPromise.set_value(std::string(buf.buffer));
});

Expand Down
1 change: 0 additions & 1 deletion src/environment/xplane/XPlaneEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class XPlaneEnvironment: public Environment {
Location nullLocation { 0, 0, 0, 0 };
std::atomic<float> lastDrawTime{};
std::string aircraftPath;
bool isXP12;

// State
std::mutex stateMutex;
Expand Down

0 comments on commit aa5892e

Please sign in to comment.