1#include "../Viewscreen/WeatherOverrides.h"
2#include "../Viewscreen/CloudVolume.h"
3#include <cstdlib>
4#include <clocale>
5#include <iostream>
6
7static void Check(bool condition, const char* message)
8{
9 if (!condition) { std::cerr << "FAIL: " << message << '\n'; std::exit(1); }
10}
11
12int main()
13{
14 float value = 7.f;
15 for (const auto* text : {L"2.5", L"+2.5", L" 2.5 "})
20 for (const auto* text : {L"", L" ", L"-", L"+", L"+-1", L"2.5junk", L"2.5 3", L"2,5", L"nan", L"inf",
21 L"1e999", L"1e-999", L"0", L"1", L"1.99", L"16.01", L"-0.5", L"-2"})
22 {
23 value = 7.f;
25 "invalid rain leaves the prior value alone");
26 }
33 Check(std::setlocale(LC_NUMERIC, "French_France.1252") != nullptr, "French numeric locale available");
36 std::setlocale(LC_NUMERIC, "C");
37
38 float weatherBase = 1.8f, baseOverride = -1.f, smoothBase = 1.2f;
40 Check(smoothBase == .125f && weatherBase == 1.8f, "base snaps without overwriting weather");
41 weatherBase = 2.4f;
44 Check(smoothBase == 2.4f, "base reset uses latest weather independently");
45 for (const auto* text : {L"0.010", L"0.150", L"0.500", L"1.5", L"42.16", L"168.64", L"-1"})
47 for (const auto* text : {L"0", L"0.009", L"-0.1", L"168.641", L"nan", L"inf", L"0.5junk", L"0,5"})
48 {
49 value = 42.16f;
51 "invalid visibility cannot set zero fog distance or silently change the range");
52 }
53 const auto near = [](float a, float b) { return std::fabs(a-b) < .0001f; };
54 const float fog = .5f;
58 "surface fog does not obscure orbit");
59
60
61
62 for (float surface : {-.15f, 0.f, .048f, .3f, 2.f})
63 for (float ceiling : {0.f, .025f, .15f})
64 for (bool resetLocal : {false, true})
65 {
69 auto manual = automatic;
70 manual.
base = surface+ceiling;
74 "automatic low cloud base must match the manual BCL override over local terrain");
75 for (float height : {.025f, .075f, .15f, .4f})
76 {
80 "automatic ground-cloud density must match the benchmarked manual base");
81 }
82 }
83
85 destination.
base = 6.960f;
90 Check(near(destination.
base, 3.079f) && near(destination.
activity, .08f),
91 "reposition applies destination cloud base and activity immediately even on a zero-time frame");
93 "reposition replaces old local wind while preserving the planet-fixed cloud formation");
96 for (int frame = 0; frame < 6000; ++frame)
99 "stationary BCL has no retained local-weather transition after reset");
102 "ordinary weather changes still blend after reposition");
103 const auto retained = destination;
105 Check(destination.
base == retained.base && destination.
activity == retained.activity,
106 "above-deck aircraft weather cannot replace the retained cloud deck during reset");
107 std::cout << "PASS: weather command parsing, overrides, reposition cloud resets and atmospheric visibility\n";
108}
Point Add(Point a, Point b)
void UpdateLocalWeather(Parameters ¶ms, Point &deckWind, bool belowDeck, float base, float activity, Point observedWind, double elapsed, bool reset=false)
constexpr float ClearVisibilityKm
Column Boundaries(Point p, const Parameters ¶ms, uint32_t seed=DefaultSeed)
Medium SampleMedium(Point p, const Parameters ¶ms, uint32_t seed=DefaultSeed)
float AtmosphericVisibility(float surfaceVisibility, float altitude, float surfaceAltitude, float clearAltitude)
bool ParseValue(const wchar_t *text, float minimum, float maximum, float &value)
float Target(float overrideValue, float weatherTarget)
void Apply(float value, float weatherTarget, float &overrideValue, float &smoothValue)