fix: sky and cockpit to turn black

Metar sky condition without base layer height (e.g. FEW///) is the cause of this issue.
Randomize the base layer height when the actual height is unknown.
This commit is contained in:
Scott Giese 2020-12-24 15:39:39 -06:00
parent bea88bb3a9
commit b2acf5a623

View File

@ -46,6 +46,7 @@
#include <sstream> #include <sstream>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include <simgear/math/sg_random.h>
#include <simgear/structure/exception.hxx> #include <simgear/structure/exception.hxx>
#include "metar.hxx" #include "metar.hxx"
@ -1068,9 +1069,12 @@ bool SGMetar::scanSkyCondition()
return false; return false;
m += i; m += i;
if (!strncmp(m, "///", 3)) // vis not measurable (e.g. because of heavy snowing) if (!strncmp(m, "///", 3)) { // vis not measurable (e.g. because of heavy snowing)
m += 3, i = -1; m += 3, i = -1;
else if (scanBoundary(&m)) { sg_srandom_time();
// randomize the base height to avoid the black sky issue
i = 50 + static_cast<int>(sg_random() * 250.0); // range [5,000, 30,000]
} else if (scanBoundary(&m)) {
_m = m; _m = m;
return true; // ignore single OVC/BKN/... return true; // ignore single OVC/BKN/...
} else if (!scanNumber(&m, &i, 3)) } else if (!scanNumber(&m, &i, 3))