Started deprecation and removal of the old star index system.

This commit is contained in:
2024-04-28 17:05:29 -04:00
parent bb26452d23
commit 01683705d0
15 changed files with 56 additions and 51 deletions
+4 -4
View File
@@ -76,7 +76,7 @@ EventHandler (BYTE selector)
if (!GET_GAME_STATE (KOHR_AH_FRENZY) if (!GET_GAME_STATE (KOHR_AH_FRENZY)
&& LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY && LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY
&& CurStarDescPtr && CurStarDescPtr
&& CurStarDescPtr->Index == SAMATRA_DEFINED) && !strcmp(CurStarDescPtr->supplement, "Sa-Matra"))
AddEvent (RELATIVE_EVENT, 0, 7, 0, KOHR_AH_GENOCIDE_EVENT); AddEvent (RELATIVE_EVENT, 0, 7, 0, KOHR_AH_GENOCIDE_EVENT);
else else
black_urquan_genocide (); black_urquan_genocide ();
@@ -90,7 +90,7 @@ EventHandler (BYTE selector)
case ZOQFOT_DISTRESS_EVENT: case ZOQFOT_DISTRESS_EVENT:
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY
&& CurStarDescPtr && CurStarDescPtr
&& CurStarDescPtr->Index == ZOQFOT_DEFINED) && !strcmp(CurStarDescPtr->supplement, "Zoq-Fot-Pik"))
AddEvent (RELATIVE_EVENT, 0, 7, 0, ZOQFOT_DISTRESS_EVENT); AddEvent (RELATIVE_EVENT, 0, 7, 0, ZOQFOT_DISTRESS_EVENT);
else else
{ {
@@ -101,7 +101,7 @@ EventHandler (BYTE selector)
case ZOQFOT_DEATH_EVENT: case ZOQFOT_DEATH_EVENT:
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY
&& CurStarDescPtr && CurStarDescPtr
&& CurStarDescPtr->Index == ZOQFOT_DEFINED) && !strcmp(CurStarDescPtr->supplement, "Zoq-Fot-Pik"))
AddEvent (RELATIVE_EVENT, 0, 7, 0, ZOQFOT_DEATH_EVENT); AddEvent (RELATIVE_EVENT, 0, 7, 0, ZOQFOT_DEATH_EVENT);
else if (GET_GAME_STATE (ZOQFOT_DISTRESS)) else if (GET_GAME_STATE (ZOQFOT_DISTRESS))
{ {
@@ -131,7 +131,7 @@ EventHandler (BYTE selector)
case SPATHI_SHIELD_EVENT: case SPATHI_SHIELD_EVENT:
if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY if (LOBYTE (GLOBAL (CurrentActivity)) == IN_INTERPLANETARY
&& CurStarDescPtr && CurStarDescPtr
&& CurStarDescPtr->Index == SPATHI_DEFINED) && !strcmp(CurStarDescPtr->supplement, "Yuffo"))
AddEvent (RELATIVE_EVENT, 0, 7, 0, SPATHI_SHIELD_EVENT); AddEvent (RELATIVE_EVENT, 0, 7, 0, SPATHI_SHIELD_EVENT);
else else
{ {
+2 -3
View File
@@ -21,11 +21,10 @@
#include <stdlib.h> #include <stdlib.h>
const GenerateFunctions * const GenerateFunctions *
getGenerateFunctions (STAR_DESC *const star) getGenerateFunctions (STAR_DESC *const star)
{ {
switch (star->Index) switch (star->Index_deprecated)
{ {
// All of the generator enums are now disabled. // All of the generator enums are now disabled.
// I can just remove the enum, after a quick play-test. // I can just remove the enum, after a quick play-test.
@@ -37,6 +36,7 @@ getGenerateFunctions (STAR_DESC *const star)
case THRADD_DEFINED: case THRADD_DEFINED:
case TAALO_PROTECTOR_DEFINED: case TAALO_PROTECTOR_DEFINED:
case ORZ_DEFINED: case ORZ_DEFINED:
case MAIDENS_DEFINED: case MAIDENS_DEFINED:
case VUX_BEAST_DEFINED: case VUX_BEAST_DEFINED:
case VUX_DEFINED: case VUX_DEFINED:
@@ -78,7 +78,6 @@ getGenerateFunctions (STAR_DESC *const star)
case URQUAN_WRECK_DEFINED: case URQUAN_WRECK_DEFINED:
default: default:
abort(); abort();
} }
} }
+22 -20
View File
@@ -216,28 +216,28 @@ BuildGroups (void)
COUNT BestPercent = 0; COUNT BestPercent = 0;
POINT universe; POINT universe;
HFLEETINFO hFleet, hNextFleet; HFLEETINFO hFleet, hNextFleet;
BYTE HomeWorld[] = const char *HomeWorld[] =
{ {
0, /* ARILOU_SHIP */ 0, /* ARILOU_SHIP */
0, /* CHMMR_SHIP */ 0, /* CHMMR_SHIP */
0, /* HUMAN_SHIP */ 0, /* HUMAN_SHIP */
ORZ_DEFINED, /* ORZ_SHIP */ "Orz", /* ORZ_SHIP */
PKUNK_DEFINED, /* PKUNK_SHIP */ "Pkunk", /* PKUNK_SHIP */
0, /* SHOFIXTI_SHIP */ 0, /* SHOFIXTI_SHIP */
SPATHI_DEFINED, /* SPATHI_SHIP */ "Yuffo", /* SPATHI_SHIP */
SUPOX_DEFINED, /* SUPOX_SHIP */ "Supox", /* SUPOX_SHIP */
THRADD_DEFINED, /* THRADDASH_SHIP */ "Thraddash", /* THRADDASH_SHIP */
UTWIG_DEFINED, /* UTWIG_SHIP */ "Utwig", /* UTWIG_SHIP */
VUX_DEFINED, /* VUX_SHIP */ "VUX", /* VUX_SHIP */
YEHAT_DEFINED, /* YEHAT_SHIP */ "Yehat", /* YEHAT_SHIP */
0, /* MELNORME_SHIP */ 0, /* MELNORME_SHIP */
DRUUGE_DEFINED, /* DRUUGE_SHIP */ "Druuge", /* DRUUGE_SHIP */
ILWRATH_DEFINED, /* ILWRATH_SHIP */ "Ilwrath", /* ILWRATH_SHIP */
MYCON_DEFINED, /* MYCON_SHIP */ "Mycon", /* MYCON_SHIP */
0, /* SLYLANDRO_SHIP */ 0, /* SLYLANDRO_SHIP */
UMGAH_DEFINED, /* UMGAH_SHIP */ "Umgah", /* UMGAH_SHIP */
0, /* URQUAN_SHIP */ 0, /* URQUAN_SHIP */
ZOQFOT_DEFINED, /* ZOQFOTPIK_SHIP */ "Zoq-Fot-Pik", /* ZOQFOTPIK_SHIP */
0, /* SYREEN_SHIP */ 0, /* SYREEN_SHIP */
0, /* BLACK_URQUAN_SHIP */ 0, /* BLACK_URQUAN_SHIP */
@@ -277,15 +277,15 @@ BuildGroups (void)
{ {
SIZE dx, dy; SIZE dx, dy;
DWORD d_squared; DWORD d_squared;
BYTE race_enc;
race_enc = HomeWorld[Index]; const char *const race_name = HomeWorld[Index];
if (race_enc && CurStarDescPtr->Index == race_enc) if (race_name && !strcmp(CurStarDescPtr->supplement, race_name) &&
(CurStarDescPtr->supArg == 0 || !strcmp(CurStarDescPtr->supArg, "Homeworld")))
{ // In general, there are always ships at the Homeworld for { // In general, there are always ships at the Homeworld for
// the races specified in HomeWorld[] array. // the races specified in HomeWorld[] array.
BestIndex = Index; BestIndex = Index;
BestPercent = 70; BestPercent = 70;
if (race_enc == SPATHI_DEFINED || race_enc == SUPOX_DEFINED) if (!strcmp(race_name, "Spathi") || !strcmp(race_name, "Supox"))
BestPercent = 2; BestPercent = 2;
// Terminate the loop! // Terminate the loop!
hNextFleet = 0; hNextFleet = 0;
@@ -349,14 +349,16 @@ FoundHome:
{ {
RACE_ENCOUNTER_MAKEUP RACE_ENCOUNTER_MAKEUP
}; };
const char *race_name = HomeWorld[Index];
which_group = 0; which_group = 0;
num_groups = ((COUNT)TFB_Random () % (BestPercent >> 1)) + 1; num_groups = ((COUNT)TFB_Random () % (BestPercent >> 1)) + 1;
if (num_groups > MAX_BATTLE_GROUPS) if (num_groups > MAX_BATTLE_GROUPS)
num_groups = MAX_BATTLE_GROUPS; num_groups = MAX_BATTLE_GROUPS;
else if (num_groups < 5 else if (num_groups < 5
&& (Index = HomeWorld[BestIndex]) && (race_name = HomeWorld[BestIndex])
&& CurStarDescPtr->Index == Index) && (!strcmp(CurStarDescPtr->supplement, race_name) &&
(CurStarDescPtr->supArg == 0 || !strcmp(CurStarDescPtr->supArg, "Homeworld"))))
num_groups = 5; num_groups = 5;
do do
{ {
+4 -4
View File
@@ -1424,7 +1424,7 @@ SeedUniverse (void)
// A player-created QuasiSpace portal is opening. // A player-created QuasiSpace portal is opening.
static POINT portal_pt; static POINT portal_pt;
SD[i].Index = ((portalCounter - 1) >> 1) + 18; SD[i].Index_deprecated = ((portalCounter - 1) >> 1) + 18;
if (portalCounter == 1) if (portalCounter == 1)
portal_pt = universe; portal_pt = universe;
SD[i].star_pt = portal_pt; SD[i].star_pt = portal_pt;
@@ -1439,11 +1439,11 @@ SeedUniverse (void)
if (arilouSpaceCounter) if (arilouSpaceCounter)
{ {
// The periodically appearing QuasiSpace portal is open. // The periodically appearing QuasiSpace portal is open.
SD[i].Index = arilouSpaceCounter >> 1; SD[i].Index_deprecated = arilouSpaceCounter >> 1;
if (arilouSpaceSide <= 1) if (arilouSpaceSide <= 1)
{ {
// The player is in HyperSpace // The player is in HyperSpace
SD[i].Index += 18; SD[i].Index_deprecated += 18;
SD[i].star_pt.x = ARILOU_SPACE_X; SD[i].star_pt.x = ARILOU_SPACE_X;
SD[i].star_pt.y = ARILOU_SPACE_Y; SD[i].star_pt.y = ARILOU_SPACE_Y;
} }
@@ -1492,7 +1492,7 @@ SeedUniverse (void)
LockElement (hHyperSpaceElement, &HyperSpaceElementPtr); LockElement (hHyperSpaceElement, &HyperSpaceElementPtr);
HyperSpaceElementPtr->current.image.frame = SetAbsFrameIndex ( HyperSpaceElementPtr->current.image.frame = SetAbsFrameIndex (
hyperstars[1 + (GET_GAME_STATE (ARILOU_SPACE_SIDE) >> 1)], hyperstars[1 + (GET_GAME_STATE (ARILOU_SPACE_SIDE) >> 1)],
SD[i].Index); SD[i].Index_deprecated);
HyperSpaceElementPtr->preprocess_func = NULL; HyperSpaceElementPtr->preprocess_func = NULL;
HyperSpaceElementPtr->postprocess_func = NULL; HyperSpaceElementPtr->postprocess_func = NULL;
HyperSpaceElementPtr->collision_func = arilou_space_collision; HyperSpaceElementPtr->collision_func = arilou_space_collision;
+3 -1
View File
@@ -445,7 +445,9 @@ LoadStarDesc (STAR_DESC *SDPtr, void *fh)
read_16s(fh, &SDPtr->star_pt.x); read_16s(fh, &SDPtr->star_pt.x);
read_16s(fh, &SDPtr->star_pt.y); read_16s(fh, &SDPtr->star_pt.y);
read_8 (fh, &SDPtr->Type); read_8 (fh, &SDPtr->Type);
read_8 (fh, &SDPtr->Index); // TODO: Do I need to load the strings, now that the save gets involved?
// Maybe I just need to overhaul the save system, at this point?
read_8 (fh, &SDPtr->Index_deprecated);
read_8 (fh, &SDPtr->Prefix); read_8 (fh, &SDPtr->Prefix);
read_8 (fh, &SDPtr->Postfix); read_8 (fh, &SDPtr->Postfix);
} }
+3 -1
View File
@@ -595,7 +595,9 @@ LoadStarDesc (STAR_DESC *SDPtr, DECODE_REF fh)
cread_16s(fh, &SDPtr->star_pt.x); cread_16s(fh, &SDPtr->star_pt.x);
cread_16s(fh, &SDPtr->star_pt.y); cread_16s(fh, &SDPtr->star_pt.y);
cread_8 (fh, &SDPtr->Type); cread_8 (fh, &SDPtr->Type);
cread_8 (fh, &SDPtr->Index); // TODO: Do I need to load the strings, now that the save gets involved?
// Maybe I just need to overhaul the save system, at this point?
cread_8 (fh, &SDPtr->Index_deprecated);
cread_8 (fh, &SDPtr->Prefix); cread_8 (fh, &SDPtr->Prefix);
cread_8 (fh, &SDPtr->Postfix); cread_8 (fh, &SDPtr->Postfix);
} }
+2 -2
View File
@@ -574,8 +574,8 @@ STAR_DESC starmap_array[] =
{{2354, 3291}, MAKE_STAR (SUPER_GIANT_STAR, RED_BODY, -1), 0, 1, 106, "Melnorme", "4"}, {{2354, 3291}, MAKE_STAR (SUPER_GIANT_STAR, RED_BODY, -1), 0, 1, 106, "Melnorme", "4"},
{{ 229, 3666}, MAKE_STAR (DWARF_STAR, GREEN_BODY, -1), 0, 1, 76, "Ilwrath"}, {{ 229, 3666}, MAKE_STAR (DWARF_STAR, GREEN_BODY, -1), 0, 1, 76, "Ilwrath"},
{{2416, 3687}, MAKE_STAR (GIANT_STAR, ORANGE_BODY, -1), 0, 5, 109, "Yuffo"}, {{2416, 3687}, MAKE_STAR (GIANT_STAR, ORANGE_BODY, -1), 0, 5, 109, "Spathi"},
{{4125, 3770}, MAKE_STAR (DWARF_STAR, BLUE_BODY, -1), 0, 0, 114, "Syreen Gaia"}, {{4125, 3770}, MAKE_STAR (DWARF_STAR, BLUE_BODY, -1), 0, 0, 114, "Syreen"},
{{5937, 3937}, MAKE_STAR (DWARF_STAR, ORANGE_BODY, -1), 0, 5, 10, "Syreen Vault"}, {{5937, 3937}, MAKE_STAR (DWARF_STAR, ORANGE_BODY, -1), 0, 5, 10, "Syreen Vault"},
{{7416, 5083}, MAKE_STAR (DWARF_STAR, GREEN_BODY, -1), 0, 3, 68, "Rainbow"}, {{7416, 5083}, MAKE_STAR (DWARF_STAR, GREEN_BODY, -1), 0, 3, 68, "Rainbow"},
+5 -5
View File
@@ -234,7 +234,7 @@ UseCaster (void)
if (playerInPlanetOrbit () if (playerInPlanetOrbit ()
&& matchWorld (pSolarSysState, pSolarSysState->pOrbitalDesc, && matchWorld (pSolarSysState, pSolarSysState->pOrbitalDesc,
1, MATCH_PLANET) 1, MATCH_PLANET)
&& CurStarDescPtr->Index == CHMMR_DEFINED && !strcmp(CurStarDescPtr->supplement, "Chmmr")
&& !GET_GAME_STATE (CHMMR_UNLEASHED)) && !GET_GAME_STATE (CHMMR_UNLEASHED))
{ {
// In orbit around the Chenjesu/Mmrnmhrm home planet. // In orbit around the Chenjesu/Mmrnmhrm home planet.
@@ -255,7 +255,7 @@ UseCaster (void)
BOOLEAN FoundIlwrath; BOOLEAN FoundIlwrath;
HIPGROUP hGroup; HIPGROUP hGroup;
FoundIlwrath = (CurStarDescPtr->Index == ILWRATH_DEFINED) FoundIlwrath = (!strcmp(CurStarDescPtr->supplement, "Ilwrath"))
&& StartSphereTracking (ILWRATH_SHIP); && StartSphereTracking (ILWRATH_SHIP);
// In the Ilwrath home system and they are alive? // In the Ilwrath home system and they are alive?
@@ -280,7 +280,7 @@ UseCaster (void)
ReinitQueue (&GLOBAL (ip_group_q)); ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
if (CurStarDescPtr->Index == ILWRATH_DEFINED) if (!strcmp(CurStarDescPtr->supplement, "Ilwrath"))
{ {
// Ilwrath home system. // Ilwrath home system.
SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 4); SET_GAME_STATE (GLOBAL_FLAGS_AND_DATA, 1 << 4);
@@ -329,7 +329,7 @@ InvokeDevice (BYTE which_device)
PlayMenuSound (MENU_SOUND_INVOKED); PlayMenuSound (MENU_SOUND_INVOKED);
SleepThreadUntil (FadeScreen (FadeAllToWhite, ONE_SECOND * 1) SleepThreadUntil (FadeScreen (FadeAllToWhite, ONE_SECOND * 1)
+ (ONE_SECOND * 2)); + (ONE_SECOND * 2));
if (CurStarDescPtr->Index != CHMMR_DEFINED if (!strcmp(CurStarDescPtr->supplement, "Chmmr")
|| !matchWorld (pSolarSysState, || !matchWorld (pSolarSysState,
pSolarSysState->pOrbitalDesc, pSolarSysState->pOrbitalDesc,
1, MATCH_PLANET)) 1, MATCH_PLANET))
@@ -394,7 +394,7 @@ InvokeDevice (BYTE which_device)
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0); assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
} }
if (CurStarDescPtr->Index == SAMATRA_DEFINED) if (!strcmp(CurStarDescPtr->supplement, "Sa-Matra"))
{ {
SET_GAME_STATE (READY_TO_CONFUSE_URQUAN, 1); SET_GAME_STATE (READY_TO_CONFUSE_URQUAN, 1);
} }
+2 -2
View File
@@ -268,7 +268,7 @@ namespace Planets ::detail:: Generate_m
std::cerr << " yes" << std::endl; std::cerr << " yes" << std::endl;
if( star.Index ) if( star.Index_deprecated )
{ {
const std::string mesg= "Solar system with modern generator (`"s const std::string mesg= "Solar system with modern generator (`"s
+ star.supplement + "`) has a legacy index!"; + star.supplement + "`) has a legacy index!";
@@ -315,7 +315,7 @@ extern "C"
// If there's a legacy builder, we must have no supplement. // If there's a legacy builder, we must have no supplement.
// We just go to the old way of doing things... // We just go to the old way of doing things...
if( desc->Index ) if( desc->Index_deprecated )
{ {
assert( desc->supplement == nullptr ); assert( desc->supplement == nullptr );
solarSys->genFuncs= getGenerateFunctions( desc ); solarSys->genFuncs= getGenerateFunctions( desc );
@@ -54,7 +54,7 @@ namespace
auto init= [] auto init= []
{ {
Generator::add( "Yuffo", std::make_unique< GenerateSpathi >() ); Generator::add( "Spathi", std::make_unique< GenerateSpathi >() );
return 0xDEADBEEF; return 0xDEADBEEF;
}(); }();
@@ -38,7 +38,7 @@ namespace
auto init= [] auto init= []
{ {
Generator::add( "Syreen Gaia", std::make_unique< GenerateSyreen >() ); Generator::add( "Syreen", std::make_unique< GenerateSyreen >() );
return 0xDEADBEEF; return 0xDEADBEEF;
}(); }();
+1 -1
View File
@@ -140,7 +140,7 @@ struct star_desc
{ {
POINT star_pt; POINT star_pt;
BYTE Type; BYTE Type;
BYTE Index; BYTE Index_deprecated;
BYTE Prefix; BYTE Prefix;
BYTE Postfix; BYTE Postfix;
+3 -3
View File
@@ -1753,7 +1753,7 @@ GetNamedPlanetaryBody (void)
assert (pSolarSysState->pOrbitalDesc != NULL); assert (pSolarSysState->pOrbitalDesc != NULL);
if (CurStarDescPtr->Index == SOL_DEFINED) if (!strcmp(CurStarDescPtr->supplement, "Sol"))
{ // Planets and moons in Sol { // Planets and moons in Sol
int planet; int planet;
int moon; int moon;
@@ -1821,7 +1821,7 @@ GetNamedPlanetaryBody (void)
break; break;
} }
} }
else if (CurStarDescPtr->Index == SPATHI_DEFINED) else if (!strcmp(CurStarDescPtr->supplement, "Spathi"))
{ {
if (matchWorld (pSolarSysState, pSolarSysState->pOrbitalDesc, if (matchWorld (pSolarSysState, pSolarSysState->pOrbitalDesc,
0, MATCH_PLANET)) 0, MATCH_PLANET))
@@ -1831,7 +1831,7 @@ GetNamedPlanetaryBody (void)
#endif // NOTYET #endif // NOTYET
} }
} }
else if (CurStarDescPtr->Index == SAMATRA_DEFINED) else if (!strcmp(CurStarDescPtr->supplement, "Sa-Matra"))
{ {
if (matchWorld (pSolarSysState, pSolarSysState->pOrbitalDesc, 4, 0)) if (matchWorld (pSolarSysState, pSolarSysState->pOrbitalDesc, 4, 0))
{ // Sa-Matra { // Sa-Matra
+1 -1
View File
@@ -426,7 +426,7 @@ SaveStarDesc (const STAR_DESC *SDPtr, uio_Stream *fh)
write_16 (fh, SDPtr->star_pt.x); write_16 (fh, SDPtr->star_pt.x);
write_16 (fh, SDPtr->star_pt.y); write_16 (fh, SDPtr->star_pt.y);
write_8 (fh, SDPtr->Type); write_8 (fh, SDPtr->Type);
write_8 (fh, SDPtr->Index); write_8 (fh, SDPtr->Index_deprecated);
write_8 (fh, SDPtr->Prefix); write_8 (fh, SDPtr->Prefix);
write_8 (fh, SDPtr->Postfix); write_8 (fh, SDPtr->Postfix);
} }
+2 -2
View File
@@ -816,12 +816,12 @@ dumpSystem (FILE *out, const STAR_DESC *star, const SOLARSYS_STATE *system)
snprintf (buf, sizeof buf, "%s %s", snprintf (buf, sizeof buf, "%s %s",
bodyColorString (STAR_COLOR(star->Type)), bodyColorString (STAR_COLOR(star->Type)),
starTypeString (STAR_TYPE(star->Type))); starTypeString (STAR_TYPE(star->Type)));
fprintf (out, "%-22s (%3d.%1d, %3d.%1d) %-19s %s\n", fprintf (out, "%-22s (%3d.%1d, %3d.%1d) %-19s %s %s\n",
name, name,
star->star_pt.x / 10, star->star_pt.x % 10, star->star_pt.x / 10, star->star_pt.x % 10,
star->star_pt.y / 10, star->star_pt.y % 10, star->star_pt.y / 10, star->star_pt.y % 10,
buf, buf,
starPresenceString (star->Index)); star->supplement, star->supArg);
(void) system; /* satisfy compiler */ (void) system; /* satisfy compiler */
} }