From 47c227943bb6a2248c999fa867be5cef7f45694a Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sun, 28 Apr 2024 02:05:04 -0400 Subject: [PATCH] Supplement argument consistency checking. With the need to start handling the supplemental argument, I'll need a hook for those handlers to slip in their checks that nothing is wrong. --- sc2/src/uqm/planets/generate-base.cpp | 8 ++++++++ sc2/src/uqm/planets/generate.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/sc2/src/uqm/planets/generate-base.cpp b/sc2/src/uqm/planets/generate-base.cpp index c1e02c111..0c800f08e 100644 --- a/sc2/src/uqm/planets/generate-base.cpp +++ b/sc2/src/uqm/planets/generate-base.cpp @@ -79,6 +79,8 @@ namespace Planets ::detail:: Generate_m Generator::~Generator()= default; + void Generator::checkSupplementRequirements( const std::optional< std::string > & ) {} + // All of the default C++ generator functions forward to the // plain C default impls. The idea is that you derive your @@ -273,6 +275,12 @@ namespace Planets ::detail:: Generate_m throw std::runtime_error{ mesg }; } + + std::cerr << "Performing supplementary argument checks for `" << star.supplement + << "`..." << std::endl; + const auto name= star.supplement; + auto gen= registry().at( name ).get(); + gen->checkSupplementRequirements( star.supArg ? star.supArg : std::optional< std::string >{} ); } } } diff --git a/sc2/src/uqm/planets/generate.h b/sc2/src/uqm/planets/generate.h index 2eb7e089f..2431617de 100644 --- a/sc2/src/uqm/planets/generate.h +++ b/sc2/src/uqm/planets/generate.h @@ -123,6 +123,7 @@ void SetupGeneratorForSolarSystem( STAR_DESC *desc, SOLARSYS_STATE *state ); #include #include +#include namespace Planets ::detail:: Generate_m { @@ -168,6 +169,8 @@ namespace Planets ::detail:: Generate_m PLANET_DESC *world, COUNT whichNode )= 0; virtual bool pickupLife( SolarSystem *solarSys, PLANET_DESC *world, COUNT whichNode )= 0; + + virtual void checkSupplementRequirements( const std::optional< std::string > & ); // Normally does nothing. }; class exports::DefaultGenerator