From b2acf5a623a3bb059bc1f3811ecff13589688b41 Mon Sep 17 00:00:00 2001 From: Scott Giese Date: Thu, 24 Dec 2020 15:39:39 -0600 Subject: [PATCH] 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. --- simgear/environment/metar.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/simgear/environment/metar.cxx b/simgear/environment/metar.cxx index 3a70842e..789f7a0d 100644 --- a/simgear/environment/metar.cxx +++ b/simgear/environment/metar.cxx @@ -46,6 +46,7 @@ #include #include +#include #include #include "metar.hxx" @@ -1068,9 +1069,12 @@ bool SGMetar::scanSkyCondition() return false; 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; - else if (scanBoundary(&m)) { + sg_srandom_time(); + // randomize the base height to avoid the black sky issue + i = 50 + static_cast(sg_random() * 250.0); // range [5,000, 30,000] + } else if (scanBoundary(&m)) { _m = m; return true; // ignore single OVC/BKN/... } else if (!scanNumber(&m, &i, 3))