Index: source/scriptinterface/ScriptInterface.cpp =================================================================== --- source/scriptinterface/ScriptInterface.cpp +++ source/scriptinterface/ScriptInterface.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -260,31 +261,15 @@ g_Profiler2.RecordAttribute("%s", name); } -// Math override functions: - -// boost::uniform_real is apparently buggy in Boost pre-1.47 - for integer generators -// it returns [min,max], not [min,max). The bug was fixed in 1.47. -// We need consistent behaviour, so manually implement the correct version: -static double generate_uniform_real(boost::rand48& rng, double min, double max) -{ - while (true) - { - double n = (double)(rng() - rng.min()); - double d = (double)(rng.max() - rng.min()) + 1.0; - ENSURE(d > 0 && n >= 0 && n <= d); - double r = n / d * (max - min) + min; - if (r < max) - return r; - } -} - } // anonymous namespace bool ScriptInterface::MathRandom(double& nbr) const { if (m->m_rng == nullptr) return false; - nbr = generate_uniform_real(*(m->m_rng), 0.0, 1.0); + + boost::uniform_real dist(0.0, 1.0); + nbr = dist(*(m->m_rng)); return true; }