diff --git a/sc2/src/sc2code/planets/gencol.c b/sc2/src/sc2code/planets/gencol.c index 9d4b388fe..bad0e46b3 100644 --- a/sc2/src/sc2code/planets/gencol.c +++ b/sc2/src/sc2code/planets/gencol.c @@ -82,7 +82,7 @@ GenerateColony (BYTE control) PPLANET_DESC pMinPlanet; pMinPlanet = &pSolarSysState->PlanetDesc[0]; - FillOrbits ((BYTE)~0, pMinPlanet, FALSE); + FillOrbits (pSolarSysState, (BYTE)~0, pMinPlanet, FALSE); pMinPlanet->radius = EARTH_RADIUS * 115L / 100; angle = ARCTAN (pMinPlanet->location.x, pMinPlanet->location.y); diff --git a/sc2/src/sc2code/planets/genshof.c b/sc2/src/sc2code/planets/genshof.c index 81e11f4d0..6e37dd3e4 100644 --- a/sc2/src/sc2code/planets/genshof.c +++ b/sc2/src/sc2code/planets/genshof.c @@ -130,7 +130,8 @@ GenerateShofixti (BYTE control) pCurDesc->data_index = METAL_WORLD; } - FillOrbits (NUM_PLANETS, &pSolarSysState->PlanetDesc[0], TRUE); + FillOrbits (pSolarSysState, + NUM_PLANETS, &pSolarSysState->PlanetDesc[0], TRUE); break; } default: diff --git a/sc2/src/sc2code/planets/genspa.c b/sc2/src/sc2code/planets/genspa.c index 21924cbe0..516891f8a 100644 --- a/sc2/src/sc2code/planets/genspa.c +++ b/sc2/src/sc2code/planets/genspa.c @@ -94,7 +94,9 @@ GenerateSpathi (BYTE control) PPLANET_DESC pMinPlanet; pMinPlanet = &pSolarSysState->PlanetDesc[0]; - FillOrbits (pSolarSysState->SunDesc[0].NumPlanets = 1, pMinPlanet, FALSE); + FillOrbits (pSolarSysState, + pSolarSysState->SunDesc[0].NumPlanets = 1, pMinPlanet, + FALSE); pMinPlanet->radius = EARTH_RADIUS * 1150L / 100; angle = ARCTAN (pMinPlanet->location.x, pMinPlanet->location.y); diff --git a/sc2/src/sc2code/planets/orbits.c b/sc2/src/sc2code/planets/orbits.c index 8ad9f2dac..ee6d7c6bb 100644 --- a/sc2/src/sc2code/planets/orbits.c +++ b/sc2/src/sc2code/planets/orbits.c @@ -469,8 +469,8 @@ YellowDistribution (BYTE which_world) #define SUPERGIANT_GASG_DIST SCALE_RADIUS (33) void -FillOrbits (BYTE NumPlanets, PPLANET_DESC pBaseDesc, BOOLEAN - TypesDefined) +FillOrbits (PSOLARSYS_STATE system, + BYTE NumPlanets, PPLANET_DESC pBaseDesc, BOOLEAN TypesDefined) { /* Generate Planets in orbit around star */ BYTE StarColor, PlanetCount, MaxPlanet; BOOLEAN GeneratingMoons; @@ -492,7 +492,7 @@ char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'}; #endif /* DEBUG_ORBITS */ pPD = pBaseDesc; - StarSize = pSolarSysState->SunDesc[0].data_index; + StarSize = system->SunDesc[0].data_index; StarColor = STAR_COLOR (CurStarDescPtr->Type); if (NumPlanets == (BYTE)~0) @@ -501,7 +501,7 @@ char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'}; while ((NumPlanets = (BYTE)(LOWORD (TFB_Random()) % MAX_GENERATED_PLANETS)) == 0) ; - pSolarSysState->SunDesc[0].NumPlanets = NumPlanets; + system->SunDesc[0].NumPlanets = NumPlanets; } #ifdef DEBUG_ORBITS @@ -510,7 +510,7 @@ char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'}; scolor[STAR_COLOR (CurStarDescPtr->Type)], stype[STAR_TYPE (CurStarDescPtr->Type)]); #endif /* DEBUG_ORBITS */ - GeneratingMoons = (BOOLEAN) (pBaseDesc == pSolarSysState->MoonDesc); + GeneratingMoons = (BOOLEAN) (pBaseDesc == system->MoonDesc); if (GeneratingMoons) MaxPlanet = FIRST_LARGE_ROCKY_WORLD; else diff --git a/sc2/src/sc2code/planets/planets.h b/sc2/src/sc2code/planets/planets.h index 841827d10..56ce16d97 100644 --- a/sc2/src/sc2code/planets/planets.h +++ b/sc2/src/sc2code/planets/planets.h @@ -203,8 +203,8 @@ extern void DrawSystem (SIZE radius, BOOLEAN IsInnerSystem); extern void DrawOval (PRECT pRect, BYTE num_off_pixels); extern void DrawFilledOval (PRECT pRect); extern void DoMissions (void); -extern void FillOrbits (BYTE NumPlanets, PPLANET_DESC pBaseDesc, BOOLEAN - TypesDefined); +extern void FillOrbits (PSOLARSYS_STATE system, + BYTE NumPlanets, PPLANET_DESC pBaseDesc, BOOLEAN TypesDefined); extern void ScanSystem (void); extern void ChangeSolarSys (void); extern BOOLEAN DoFlagshipCommands (PMENU_STATE pMS); diff --git a/sc2/src/sc2code/planets/solarsys.c b/sc2/src/sc2code/planets/solarsys.c index b73630858..f17b707a5 100644 --- a/sc2/src/sc2code/planets/solarsys.c +++ b/sc2/src/sc2code/planets/solarsys.c @@ -62,15 +62,15 @@ static SIZE old_radius; BYTE draw_sys_flags = DRAW_STARS | DRAW_PLANETS | DRAW_ORBITS | DRAW_HYPER_COORDS | GRAB_BKGND; +// NB. This function modifies the RNG state. static void -GeneratePlanets (void) +GeneratePlanets (PSOLARSYS_STATE system) { COUNT i; - PPLANET_DESC pCurDesc; + PPLANET_DESC planet; - for (i = pSolarSysState->SunDesc[0].NumPlanets, - pCurDesc = &pSolarSysState->PlanetDesc[0]; i; - --i, ++pCurDesc) + for (i = system->SunDesc[0].NumPlanets, + planet = &system->PlanetDesc[0]; i; --i, ++planet) { DWORD rand_val; BYTE byte_val; @@ -81,7 +81,7 @@ GeneratePlanets (void) byte_val = LOBYTE (rand_val); num_moons = 0; - type = PlanData[pCurDesc->data_index & ~PLANET_SHIELDED].Type; + type = PlanData[planet->data_index & ~PLANET_SHIELDED].Type; switch (PLANSIZE (type)) { case LARGE_ROCKY_WORLD: @@ -109,7 +109,7 @@ GeneratePlanets (void) } break; } - pCurDesc->NumPlanets = num_moons; + planet->NumPlanets = num_moons; } } @@ -1638,13 +1638,15 @@ GenerateRandomIP (BYTE control) break; } case GENERATE_MOONS: - FillOrbits (pSolarSysState->pBaseDesc->NumPlanets, + FillOrbits (pSolarSysState, + pSolarSysState->pBaseDesc->NumPlanets, &pSolarSysState->MoonDesc[0], FALSE); break; case GENERATE_PLANETS: { - FillOrbits ((BYTE)~0, &pSolarSysState->PlanetDesc[0], FALSE); - GeneratePlanets(); + FillOrbits (pSolarSysState, + (BYTE)~0, &pSolarSysState->PlanetDesc[0], FALSE); + GeneratePlanets (pSolarSysState); break; } } diff --git a/sc2/src/sc2code/planets/surface.c b/sc2/src/sc2code/planets/surface.c index 785f17efd..453449c60 100644 --- a/sc2/src/sc2code/planets/surface.c +++ b/sc2/src/sc2code/planets/surface.c @@ -254,7 +254,8 @@ GenerateLifeForms (SYSTEM_INFOPTR SysInfoPtr, PCOUNT pwhich_life) { DWORD old_rand; - old_rand = TFB_SeedRandom (SysInfoPtr->PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]); + old_rand = TFB_SeedRandom ( + SysInfoPtr->PlanetInfo.ScanSeed[BIOLOGICAL_SCAN]); *pwhich_life = CalcLifeForms (SysInfoPtr, *pwhich_life); return (TFB_SeedRandom (old_rand)); }