Validation really only needs to be done once.

Also be a bit more noisy with validation.
This commit is contained in:
2024-04-28 02:21:25 -04:00
parent 47c227943b
commit 456d2aa40c
+12 -1
View File
@@ -235,6 +235,8 @@ namespace Planets ::detail:: Generate_m
void void
validateAllStars() validateAllStars()
{ {
std::cerr << "Checking if any stars are out of required sorting order..."
<< std::endl;
const auto where= std::is_sorted_until( GetAllStars(), const auto where= std::is_sorted_until( GetAllStars(),
GetAllStars() + GetStarCount(), GetAllStars() + GetStarCount(),
[]( const auto &lhs_, const auto &rhs_ ) []( 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 >{} ); 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 void
SetupGeneratorForSolarSystem( STAR_DESC *const desc, SolarSystem *const solarSys ) 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, // Must either have a legacy constructor or a named lookup,
// but not both. // but not both.