From fde9e63d8b85fb6ff9421892093ad73a91ac595d Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Fri, 26 Apr 2024 03:40:30 -0400 Subject: [PATCH] Several generators are "sorta parameterized" -- make ready for that. The VUX, Utwig, Melnorme and others all have branching paths on the actual `XXX_DEFINED` enum value. This is an ersatz parameter. I'll provide an extra string parameter for all generators, that lives in the `SolarSystem` type (for now). The table can now just mention the static string which indicates the kind of variation to build. (Eventually, this will become more dynamic, once I have support for runtime-insertion of stars.) --- sc2/src/uqm/gendef.c | 4 +++- sc2/src/uqm/gendef.h | 2 +- sc2/src/uqm/planets/planets.h | 2 ++ sc2/src/uqm/planets/solarsys.c | 3 ++- sc2/src/uqm/uqmdebug.c | 3 ++- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sc2/src/uqm/gendef.c b/sc2/src/uqm/gendef.c index ccc0cde28..589b0700d 100644 --- a/sc2/src/uqm/gendef.c +++ b/sc2/src/uqm/gendef.c @@ -58,9 +58,10 @@ extern struct GeneratorBase cxxDefaultPlanetGen; const GenerateFunctions * -getGenerateFunctions (STAR_DESC *const star, void **sup ) +getGenerateFunctions (STAR_DESC *const star, void **sup, const char **supArg ) { *sup= star->supplement; + *supArg= 0; switch (star->Index) { @@ -95,6 +96,7 @@ getGenerateFunctions (STAR_DESC *const star, void **sup ) return &generateTrapFunctions; case BURVIXESE_DEFINED: return &generateBurvixeseFunctions; + abort(); case DRUUGE_DEFINED: return &generateDruugeFunctions; case BOMB_DEFINED: diff --git a/sc2/src/uqm/gendef.h b/sc2/src/uqm/gendef.h index 52e61ce9f..3d1d099c7 100644 --- a/sc2/src/uqm/gendef.h +++ b/sc2/src/uqm/gendef.h @@ -8,7 +8,7 @@ extern "C" { #endif -const GenerateFunctions *getGenerateFunctions (STAR_DESC *star, void **sup); +const GenerateFunctions *getGenerateFunctions (STAR_DESC *star, void **sup, const char **arg ); enum { diff --git a/sc2/src/uqm/planets/planets.h b/sc2/src/uqm/planets/planets.h index 462039fda..45ad9b926 100644 --- a/sc2/src/uqm/planets/planets.h +++ b/sc2/src/uqm/planets/planets.h @@ -143,6 +143,7 @@ struct star_desc BYTE Postfix; void *supplement; // The CXX builder's pointer gets put here. + void *supArg; // Extra info for the CXX builder goes here. }; struct node_info @@ -269,6 +270,7 @@ struct solarsys_state // Since everything else probably ignores it... we can probably // avoid setting it to `nullptr`, for now... void *genSupplement; + const char *supArgument; }; extern SOLARSYS_STATE *pSolarSysState; diff --git a/sc2/src/uqm/planets/solarsys.c b/sc2/src/uqm/planets/solarsys.c index 9118db4f0..c02accd2f 100644 --- a/sc2/src/uqm/planets/solarsys.c +++ b/sc2/src/uqm/planets/solarsys.c @@ -1735,7 +1735,8 @@ ExploreSolarSys (void) memset (pSolarSysState, 0, sizeof (*pSolarSysState)); - SolarSysState.genFuncs = getGenerateFunctions (CurStarDescPtr, &SolarSysState.genSupplement); + SolarSysState.genFuncs = getGenerateFunctions (CurStarDescPtr, &SolarSysState.genSupplement, + &SolarSysState.supArgument); InitSolarSys (); SetMenuSounds (MENU_SOUND_NONE, MENU_SOUND_NONE); diff --git a/sc2/src/uqm/uqmdebug.c b/sc2/src/uqm/uqmdebug.c index 4fc540dd6..7dc8fba84 100644 --- a/sc2/src/uqm/uqmdebug.c +++ b/sc2/src/uqm/uqmdebug.c @@ -645,7 +645,8 @@ starRecurse (STAR_DESC *star, void *arg) SolarSysState.SunDesc[0].location.x = 0; SolarSysState.SunDesc[0].location.y = 0; //SolarSysState.SunDesc[0].radius = MIN_ZOOM_RADIUS; - SolarSysState.genFuncs = getGenerateFunctions (star, &SolarSysState.genSupplement); + SolarSysState.genFuncs = getGenerateFunctions (star, &SolarSysState.genSupplement, + &SolarSysState.supArgument); pSolarSysState = &SolarSysState; (*SolarSysState.genFuncs->generatePlanets) (&SolarSysState);