From 104cc02ed139f16cde4c614ed08cf70cea79faed Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Wed, 24 Apr 2024 10:09:49 -0400 Subject: [PATCH] Starbase menu is now accessible by a function. The original game did a bunch of one-off specifics to enter the starbase menu. Since I want to make this available in multiple places (even via script... and maybe by *building* new starbases), I'll need a simple function to call. I've tested it by making the Chmmr and Syreen starbase both call this function -- it works. (It's kinda neat to have starbases all over the galaxy! It totally makes for a different kind of game.) Of course, since I intend to make all planet stuff customizable via Lua -- one can make their own game have whatever they want. A main starbase, which might get conquered and then have to be relocated could be interesting. I aim to make "nearly anything" possible. --- sc2/src/uqm/planets/generate/gensol.c | 12 +++--------- sc2/src/uqm/starbase.c | 18 ++++++++++++++++++ sc2/src/uqm/starbase.h | 2 ++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/sc2/src/uqm/planets/generate/gensol.c b/sc2/src/uqm/planets/generate/gensol.c index 57da6bd8f..ecb3101a0 100644 --- a/sc2/src/uqm/planets/generate/gensol.c +++ b/sc2/src/uqm/planets/generate/gensol.c @@ -29,6 +29,8 @@ #include "../../state.h" #include "libs/mathlib.h" +#include "../../starbase.h" + static bool GenerateSol_initNpcs (SOLARSYS_STATE *solarSys); static bool GenerateSol_reinitNpcs (SOLARSYS_STATE *solarSys); @@ -260,15 +262,7 @@ GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) if (matchWorld (solarSys, world, 2, 0)) { - /* Starbase */ - PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); - ReinitQueue (&GLOBAL (ip_group_q)); - assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); - - EncounterGroup = 0; - GLOBAL (CurrentActivity) |= START_ENCOUNTER; - SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, (BYTE)~0); - return true; + return PrepareToVisitStarBase(); } DoPlanetaryAnalysis (&solarSys->SysInfo, world); diff --git a/sc2/src/uqm/starbase.c b/sc2/src/uqm/starbase.c index f1192085c..26cf0185e 100644 --- a/sc2/src/uqm/starbase.c +++ b/sc2/src/uqm/starbase.c @@ -33,6 +33,11 @@ #include "libs/graphics/gfx_common.h" #include "libs/tasklib.h" +#include "encount.h" +#include "globdata.h" +#include "state.h" +#include "grpinfo.h" + static void CleanupAfterStarBase (void); @@ -600,3 +605,16 @@ WrapText (const UNICODE *pStr, COUNT len, TEXT *tarray, SIZE field_width) return (num_lines); } +bool +PrepareToVisitStarBase( void ) +{ + PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP); + ReinitQueue (&GLOBAL (ip_group_q)); + assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); + + EncounterGroup = 0; + GLOBAL (CurrentActivity) |= START_ENCOUNTER; + SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, (BYTE)~0); + return true; +} + diff --git a/sc2/src/uqm/starbase.h b/sc2/src/uqm/starbase.h index 0bf5558ce..f9e96ffb5 100644 --- a/sc2/src/uqm/starbase.h +++ b/sc2/src/uqm/starbase.h @@ -48,6 +48,8 @@ extern COUNT WrapText (const UNICODE *pStr, COUNT len, TEXT *tarray, SIZE field_width); // XXX: Doesn't really belong in this file. +extern bool PrepareToVisitStarBase( void ); + #if defined(__cplusplus) } #endif