From 456d2aa40c40b08a8b46ec922b707def66975573 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 28 Apr 2024 02:21:25 -0400 Subject: [PATCH] Validation really only needs to be done once. Also be a bit more noisy with validation. --- sc2/src/uqm/planets/generate-base.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sc2/src/uqm/planets/generate-base.cpp b/sc2/src/uqm/planets/generate-base.cpp index 0c800f08e..d3bc96d27 100644 --- a/sc2/src/uqm/planets/generate-base.cpp +++ b/sc2/src/uqm/planets/generate-base.cpp @@ -235,6 +235,8 @@ namespace Planets ::detail:: Generate_m void validateAllStars() { + std::cerr << "Checking if any stars are out of required sorting order..." + << std::endl; const auto where= std::is_sorted_until( GetAllStars(), GetAllStars() + GetStarCount(), []( const auto &lhs_, const auto &rhs_ ) @@ -283,6 +285,15 @@ namespace Planets ::detail:: Generate_m gen->checkSupplementRequirements( star.supArg ? star.supArg : std::optional< std::string >{} ); } } + + void + stickyValidateAllStars() + { + static bool validated= false; + if( validated ) return; + validateAllStars(); + validated= true; + } } } @@ -297,7 +308,7 @@ extern "C" void SetupGeneratorForSolarSystem( STAR_DESC *const desc, SolarSystem *const solarSys ) { - if( C::debugGenerationByValidatingAllStars ) validateAllStars(); + if( C::debugGenerationByValidatingAllStars ) stickyValidateAllStars(); // Must either have a legacy constructor or a named lookup, // but not both.