diff --git a/sc2/src/uqm/planets/generate-base.cpp b/sc2/src/uqm/planets/generate-base.cpp index 0a9263cc1..c1e02c111 100644 --- a/sc2/src/uqm/planets/generate-base.cpp +++ b/sc2/src/uqm/planets/generate-base.cpp @@ -23,6 +23,7 @@ #include #include +#include #include @@ -232,6 +233,21 @@ namespace Planets ::detail:: Generate_m void validateAllStars() { + const auto where= std::is_sorted_until( GetAllStars(), + GetAllStars() + GetStarCount(), + []( const auto &lhs_, const auto &rhs_ ) + { + const auto &lhs= lhs_.star_pt; + const auto &rhs= rhs_.star_pt; + + if( lhs.y == rhs.y ) return lhs.x < rhs.x; + return lhs.y < rhs.y; + } ); + if( where != GetAllStars() + GetStarCount() ) + { + throw std::runtime_error( "Found star out of order" ); + } + for( int i= 0; i < GetStarCount(); ++i ) { const auto &star= GetAllStars()[ i ];