This updates how Sol generates to have more stuff.

It's a bunch of hacky things I threw together.  Some accurate,
some not.  Mostly just to play with the algorithms which
generate stuff -- I want the generation to be unaltered if I
slip in new stuff between planets.  To do this, I have to
understand when RNG gets updated, how, and what other constants
affect the generation computations.
This commit is contained in:
2024-04-25 23:58:59 -04:00
parent 52ddaf0d71
commit a6d5cbf4ca
2 changed files with 230 additions and 33 deletions
+209 -32
View File
@@ -20,6 +20,7 @@
#include "../lander.h"
#include "../lifeform.h"
#include "../planets.h"
#include "../../comm.h"
#include "../../build.h"
#include "../../encount.h"
#include "../../globdata.h"
@@ -31,6 +32,10 @@
#include "../../starbase.h"
#define KELVIN( t ) ( t - 273 );
#define DENSITY( d ) ( 100 * ( d / 5.513 ) );
#define RADIUS( r ) ( 100 * ( r / 6.356 ) )
static bool GenerateSol_initNpcs (SOLARSYS_STATE *solarSys);
static bool GenerateSol_reinitNpcs (SOLARSYS_STATE *solarSys);
@@ -112,18 +117,28 @@ GenerateSol_generatePlanets (SOLARSYS_STATE *solarSys)
#define SOL_SEED 334241042L
RandomContext_SeedRandom (SysGenRNG, SOL_SEED);
solarSys->SunDesc[0].NumPlanets = 9;
for (planetI = 0; planetI < 9; ++planetI)
#define SOL_PLANETS 10
solarSys->SunDesc[0].NumPlanets = SOL_PLANETS;
DWORD saved_seed;
for (planetI = 0; planetI < SOL_PLANETS; ++planetI)
{
COUNT angle;
DWORD rand_val;
UWORD word_val;
PLANET_DESC *pCurDesc = &solarSys->PlanetDesc[planetI];
pCurDesc->rand_seed = RandomContext_Random (SysGenRNG);
rand_val = pCurDesc->rand_seed;
word_val = LOWORD (rand_val);
angle = NORMALIZE_ANGLE ((COUNT)HIBYTE (word_val));
if( planetI != 4 ) /* Skip Ceres to avoid it making the rest have bizarre angles */
{
pCurDesc->rand_seed = RandomContext_Random (SysGenRNG);
rand_val = pCurDesc->rand_seed;
word_val = LOWORD (rand_val);
angle = NORMALIZE_ANGLE ((COUNT)HIBYTE (word_val));
}
else
{
angle= HALF_CIRCLE + ( OCTANT / 2 );
}
switch (planetI)
{
@@ -135,43 +150,48 @@ GenerateSol_generatePlanets (SOLARSYS_STATE *solarSys)
case 1: /* VENUS */
pCurDesc->data_index = PRIMORDIAL_WORLD;
pCurDesc->radius = EARTH_RADIUS * 72L / 100;
pCurDesc->NumPlanets = 0;
pCurDesc->NumPlanets = 2;
angle = NORMALIZE_ANGLE (FULL_CIRCLE - angle);
break;
case 2: /* EARTH */
pCurDesc->data_index = WATER_WORLD | PLANET_SHIELDED;
pCurDesc->data_index = WATER_WORLD ; //| PLANET_SHIELDED;
pCurDesc->radius = EARTH_RADIUS;
pCurDesc->NumPlanets = 2;
break;
case 3: /* MARS */
pCurDesc->data_index = DUST_WORLD;
pCurDesc->radius = EARTH_RADIUS * 152L / 100;
pCurDesc->NumPlanets = 0;
pCurDesc->NumPlanets = 3;
break;
case 4: /* JUPITER */
case 4: /* CERES */
pCurDesc->data_index= PELLUCID_WORLD;
pCurDesc->radius= EARTH_RADIUS * 277L / 100;
pCurDesc->NumPlanets= 0;
break;
case 5: /* JUPITER */
pCurDesc->data_index = RED_GAS_GIANT;
pCurDesc->radius = EARTH_RADIUS * 500L /* 520L */ / 100;
pCurDesc->NumPlanets = 4;
break;
case 5: /* SATURN */
pCurDesc->data_index = ORA_GAS_GIANT;
case 6: /* SATURN */
pCurDesc->data_index = YEL_GAS_GIANT;
pCurDesc->radius = EARTH_RADIUS * 750L /* 952L */ / 100;
pCurDesc->NumPlanets = 1;
break;
case 6: /* URANUS */
pCurDesc->data_index = GRN_GAS_GIANT;
case 7: /* URANUS */
pCurDesc->data_index = CYA_GAS_GIANT;
pCurDesc->radius = EARTH_RADIUS * 1000L /* 1916L */ / 100;
pCurDesc->NumPlanets = 0;
break;
case 7: /* NEPTUNE */
case 8: /* NEPTUNE */
pCurDesc->data_index = BLU_GAS_GIANT;
pCurDesc->radius = EARTH_RADIUS * 1250L /* 2999L */ / 100;
pCurDesc->NumPlanets = 1;
break;
case 8: /* PLUTO */
case 9: /* PLUTO */
pCurDesc->data_index = PELLUCID_WORLD;
pCurDesc->radius = EARTH_RADIUS * 1550L /* 3937L */ / 100;
pCurDesc->NumPlanets = 0;
pCurDesc->NumPlanets = 1; // Charon
angle = FULL_CIRCLE - OCTANT;
break;
}
@@ -194,6 +214,34 @@ GenerateSol_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
planetNr = planetIndex (solarSys, planet);
switch (planetNr)
{
case 1: /* "moons" of VENUS */
{
COUNT angle;
// Phobos
angle = QUADRANT;
solarSys->MoonDesc[ 0 ].data_index= TELLURIC_WORLD;
solarSys->MoonDesc[ 0 ].radius= MIN_MOON_RADIUS;
solarSys->MoonDesc[ 0 ].location.x =
COSINE (angle, solarSys->MoonDesc[ 0 ].radius);
solarSys->MoonDesc[ 0 ].location.y =
SINE (angle, solarSys->MoonDesc[ 0 ].radius);
// Deimos
#if 1
angle = HALF_CIRCLE;
solarSys->MoonDesc[ 1 ].data_index= WATER_WORLD;
solarSys->MoonDesc[ 1 ].radius= MIN_MOON_RADIUS + MOON_DELTA * .5;
solarSys->MoonDesc[ 1 ].location.x =
COSINE (angle, solarSys->MoonDesc[ 1 ].radius);
solarSys->MoonDesc[ 1 ].location.y =
SINE (angle, solarSys->MoonDesc[ 1 ].radius);
#endif
break;
}
case 2: /* moons of EARTH */
{
COUNT angle;
@@ -219,7 +267,47 @@ GenerateSol_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
SINE (angle, solarSys->MoonDesc[1].radius);
break;
}
case 4: /* moons of JUPITER */
case 3: /* moons of MARS and Mars station */
{
COUNT angle;
// Phobos
angle = QUADRANT;
solarSys->MoonDesc[ 0 ].data_index= SELENIC_WORLD;
solarSys->MoonDesc[ 0 ].radius= MIN_MOON_RADIUS * .6667;
solarSys->MoonDesc[ 0 ].location.x =
COSINE (angle, solarSys->MoonDesc[ 0 ].radius);
solarSys->MoonDesc[ 0 ].location.y =
SINE (angle, solarSys->MoonDesc[ 0 ].radius);
// Deimos
#if 1
angle = OCTANT + ( OCTANT / 2 );
solarSys->MoonDesc[ 1 ].data_index= SELENIC_WORLD;
solarSys->MoonDesc[ 1 ].radius= MIN_MOON_RADIUS * .6667 + MOON_DELTA * .40;
solarSys->MoonDesc[ 1 ].location.x =
COSINE (angle, solarSys->MoonDesc[ 1 ].radius);
solarSys->MoonDesc[ 1 ].location.y =
SINE (angle, solarSys->MoonDesc[ 1 ].radius);
#endif
#if 1
// Base
angle = 0;
solarSys->MoonDesc[ 2 ].data_index = HIERARCHY_STARBASE;
solarSys->MoonDesc[ 2 ].radius = MIN_MOON_RADIUS + ( MAX_MOONS - 1 ) * MOON_DELTA;
solarSys->MoonDesc[ 2 ].location.x =
COSINE (angle, solarSys->MoonDesc[ 2 ].radius);
solarSys->MoonDesc[ 2 ].location.y =
SINE (angle, solarSys->MoonDesc[ 2 ].radius);
#endif
break;
}
case 5: /* moons of JUPITER */
solarSys->MoonDesc[0].data_index = RADIOACTIVE_WORLD;
/* Io */
solarSys->MoonDesc[1].data_index = HALIDE_WORLD;
@@ -229,14 +317,19 @@ GenerateSol_generateMoons (SOLARSYS_STATE *solarSys, PLANET_DESC *planet)
solarSys->MoonDesc[3].data_index = PELLUCID_WORLD;
/* Callisto */
break;
case 5: /* moons of SATURN */
case 6: /* moons of SATURN */
solarSys->MoonDesc[0].data_index = ALKALI_WORLD;
/* Titan */
break;
case 7: /* moons of NEPTUNE */
case 8: /* moons of NEPTUNE */
solarSys->MoonDesc[0].data_index = VINYLOGOUS_WORLD;
/* Triton */
break;
case 9: /* moons of PLUTO */
solarSys->MoonDesc[ 0 ].data_index= PELLUCID_WORLD;
/* Charon */
break;
}
return true;
@@ -246,9 +339,37 @@ static bool
GenerateSol_generateName (const SOLARSYS_STATE *solarSys,
const PLANET_DESC *world)
{
COUNT planetNr = planetIndex (solarSys, world);
utf8StringCopy (GLOBAL_SIS (PlanetName), sizeof (GLOBAL_SIS (PlanetName)),
GAME_STRING (PLANET_NUMBER_BASE + planetNr));
fprintf( stderr, "ADAM: in `generateName` (planetNr = %d)\n", planetNr );
if( matchWorld( solarSys, world, 3, 0 ) )
{
fprintf( stderr, "ADAM: Trying to set Phobos\n" );
utf8StringCopy( GLOBAL_SIS( PlanetName ), sizeof( GLOBAL_SIS( PlanetName ) ),
"Phobos" );
}
else if( matchWorld( solarSys, world, 3, 1 ) )
{
fprintf( stderr, "ADAM: Trying to set Deimos\n" );
utf8StringCopy( GLOBAL_SIS( PlanetName ), sizeof( GLOBAL_SIS( PlanetName ) ),
"Deimos" );
}
else if( matchWorld( solarSys, world, 4, MATCH_PLANET ) )
{
fprintf( stderr, "ADAM: Trying to set Ceres\n" );
utf8StringCopy( GLOBAL_SIS( PlanetName ), sizeof( GLOBAL_SIS( PlanetName ) ),
"Ceres" );
}
else
{
fprintf( stderr, "ADAM: Trying to set from default to: %s\n", GAME_STRING( PLANET_NUMBER_BASE + planetNr ) );
COUNT xPlanetNr= planetNr;
if( xPlanetNr > 4 ) xPlanetNr-= 1;
utf8StringCopy (GLOBAL_SIS (PlanetName), sizeof (GLOBAL_SIS (PlanetName)),
GAME_STRING (PLANET_NUMBER_BASE + xPlanetNr));
}
SET_GAME_STATE (BATTLE_PLANET, solarSys->PlanetDesc[planetNr].data_index);
return true;
@@ -262,9 +383,37 @@ GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
if (matchWorld (solarSys, world, 2, 0))
{
// Earth base...
return PrepareToVisitStarBase();
}
if (matchWorld (solarSys, world, 3, 2))
{
// Mars base...
return PrepareToVisitStarBase();
}
if (matchWorld (solarSys, world, 2, MATCH_PLANET))
{
//NotifyOthers (ILWRATH_SHIP, IPNL_ALL_CLEAR);
PutGroupInfo (GROUPS_RANDOM, GROUP_SAVE_IP);
ReinitQueue (&GLOBAL (ip_group_q));
assert (CountLinks (&GLOBAL (npc_built_ship_q)) == 0);
CloneShipFragment (ANDROSYNTH_ID,
&GLOBAL (npc_built_ship_q), INFINITE_FLEET);
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
InitCommunication( SUPOX_CONVERSATION );
if (!(GLOBAL (CurrentActivity) & (CHECK_ABORT | CHECK_LOAD)))
{
GLOBAL (CurrentActivity) &= ~START_INTERPLANETARY;
ReinitQueue (&GLOBAL (npc_built_ship_q));
GetGroupInfo (GROUPS_RANDOM, GROUP_LOAD_IP);
}
}
DoPlanetaryAnalysis (&solarSys->SysInfo, world);
rand_val = RandomContext_GetSeed (SysGenRNG);
@@ -320,7 +469,7 @@ GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
solarSys->SysInfo.PlanetInfo.RotationPeriod = 246;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -53;
break;
case 4: /* JUPITER */
case 5: /* JUPITER */
solarSys->SysInfo.PlanetInfo.AtmoDensity =
GAS_GIANT_ATMOSPHERE;
solarSys->SysInfo.PlanetInfo.PlanetDensity = 24;
@@ -333,7 +482,7 @@ GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
solarSys->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 520L / 100;
break;
case 5: /* SATURN */
case 6: /* SATURN */
solarSys->SysInfo.PlanetInfo.AtmoDensity =
GAS_GIANT_ATMOSPHERE;
solarSys->SysInfo.PlanetInfo.PlanetDensity = 13;
@@ -346,7 +495,7 @@ GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
solarSys->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 952L / 100;
break;
case 6: /* URANUS */
case 7: /* URANUS */
solarSys->SysInfo.PlanetInfo.AtmoDensity =
GAS_GIANT_ATMOSPHERE;
solarSys->SysInfo.PlanetInfo.PlanetDensity = 21;
@@ -359,7 +508,7 @@ GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
solarSys->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 1916L / 100;
break;
case 7: /* NEPTUNE */
case 8: /* NEPTUNE */
solarSys->SysInfo.PlanetInfo.AtmoDensity =
GAS_GIANT_ATMOSPHERE;
solarSys->SysInfo.PlanetInfo.PlanetDensity = 28;
@@ -372,7 +521,7 @@ GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
solarSys->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 2999L / 100;
break;
case 8: /* PLUTO */
case 9: /* PLUTO */
if (!GET_GAME_STATE (FOUND_PLUTO_SPATHI))
{
LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo);
@@ -439,7 +588,32 @@ GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -18;
break;
case 4: /* moons of JUPITER */
case 3: /* moons of MARS */
{
switch( moonNr )
{
case 0: // Phobos
solarSys->SysInfo.PlanetInfo.PlanetDensity= DENSITY( 1.861 );
solarSys->SysInfo.PlanetInfo.PlanetRadius= RADIUS( .022 );
solarSys->SysInfo.PlanetInfo.Tectonics= 0;
solarSys->SysInfo.PlanetInfo.RotationPeriod= 390;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature= KELVIN( 233 );
solarSys->SysInfo.PlanetInfo.AtmoDensity = 0;
break;
case 1: // Deimos
solarSys->SysInfo.PlanetInfo.PlanetDensity= DENSITY( 1.465 );
solarSys->SysInfo.PlanetInfo.PlanetRadius= RADIUS( .006 );
solarSys->SysInfo.PlanetInfo.Tectonics= 0;
solarSys->SysInfo.PlanetInfo.RotationPeriod= 390;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature= KELVIN( 233 );
solarSys->SysInfo.PlanetInfo.AtmoDensity = 0;
break;
}
break;
}
case 5: /* moons of JUPITER */
solarSys->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 520L / 100;
switch (moonNr)
@@ -475,7 +649,7 @@ GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
}
break;
case 5: /* moon of SATURN: Titan */
case 6: /* moon of SATURN: Titan */
solarSys->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 952L / 100;
solarSys->SysInfo.PlanetInfo.AtmoDensity = 160;
@@ -487,7 +661,7 @@ GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -178;
break;
case 7: /* moon of NEPTUNE: Triton */
case 8: /* moon of NEPTUNE: Triton */
solarSys->SysInfo.PlanetInfo.PlanetToSunDist =
EARTH_RADIUS * 2999L / 100;
solarSys->SysInfo.PlanetInfo.AtmoDensity = 10;
@@ -498,6 +672,9 @@ GenerateSol_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world)
solarSys->SysInfo.PlanetInfo.RotationPeriod = 4300;
solarSys->SysInfo.PlanetInfo.SurfaceTemperature = -216;
break;
case 9: /* moon of PLUTO: Charon */
break;
}
solarSys->SysInfo.PlanetInfo.SurfaceGravity =
@@ -512,7 +689,7 @@ static COUNT
GenerateSol_generateEnergy (const SOLARSYS_STATE *solarSys,
const PLANET_DESC *world, COUNT whichNode, NODE_INFO *info)
{
if (matchWorld (solarSys, world, 8, MATCH_PLANET))
if (matchWorld (solarSys, world, 9, MATCH_PLANET))
{
/* Pluto */
// This check is needed because the retrieval bit is not set for
@@ -558,7 +735,7 @@ static bool
GenerateSol_pickupEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world,
COUNT whichNode)
{
if (matchWorld (solarSys, world, 8, MATCH_PLANET))
if (matchWorld (solarSys, world, 9, MATCH_PLANET))
{ // Pluto
assert (!GET_GAME_STATE (FOUND_PLUTO_SPATHI) && whichNode == 0);
+20
View File
@@ -1760,11 +1760,19 @@ GetNamedPlanetaryBody (void)
planet = planetIndex (pSolarSysState, pSolarSysState->pOrbitalDesc);
if (worldIsPlanet (pSolarSysState, pSolarSysState->pOrbitalDesc)
&& planet == 4 )
{
return "Ceres";
}
if( planet > 4 ) planet-= 1;
if (worldIsPlanet (pSolarSysState, pSolarSysState->pOrbitalDesc))
{ // A planet
return GAME_STRING (PLANET_NUMBER_BASE + planet);
}
// Moons
moon = moonIndex (pSolarSysState, pSolarSysState->pOrbitalDesc);
switch (planet)
@@ -1778,6 +1786,13 @@ GetNamedPlanetaryBody (void)
return GAME_STRING (PLANET_NUMBER_BASE + 9);
}
break;
case 3: // Mars
switch( moon )
{
case 0: return "Phobos";
case 1: return "Deimos";
}
break;
case 4: // Jupiter
switch (moon)
{
@@ -1799,6 +1814,11 @@ GetNamedPlanetaryBody (void)
if (moon == 0) // Triton
return GAME_STRING (PLANET_NUMBER_BASE + 15);
break;
case 8: // Pluto
if( moon == 0 ) // Charon
return "Charon";
break;
}
}
else if (CurStarDescPtr->Index == SPATHI_DEFINED)