On generation check that the whole starmap is properly sorted.
(I should probably make this check runtime-sticky... with huge dynamical games it might get a bit noticable that we slow down for each solar system load event.)
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -232,6 +233,21 @@ namespace Planets ::detail:: Generate_m
|
|||||||
void
|
void
|
||||||
validateAllStars()
|
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 )
|
for( int i= 0; i < GetStarCount(); ++i )
|
||||||
{
|
{
|
||||||
const auto &star= GetAllStars()[ i ];
|
const auto &star= GetAllStars()[ i ];
|
||||||
|
|||||||
Reference in New Issue
Block a user