Reduced the dependency on global variables.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1836 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
meep-eep
2005-07-10 00:54:54 +00:00
parent 0b2ab00143
commit 7c2e4c556d
7 changed files with 27 additions and 21 deletions
+1 -1
View File
@@ -82,7 +82,7 @@ GenerateColony (BYTE control)
PPLANET_DESC pMinPlanet; PPLANET_DESC pMinPlanet;
pMinPlanet = &pSolarSysState->PlanetDesc[0]; pMinPlanet = &pSolarSysState->PlanetDesc[0];
FillOrbits ((BYTE)~0, pMinPlanet, FALSE); FillOrbits (pSolarSysState, (BYTE)~0, pMinPlanet, FALSE);
pMinPlanet->radius = EARTH_RADIUS * 115L / 100; pMinPlanet->radius = EARTH_RADIUS * 115L / 100;
angle = ARCTAN (pMinPlanet->location.x, pMinPlanet->location.y); angle = ARCTAN (pMinPlanet->location.x, pMinPlanet->location.y);
+2 -1
View File
@@ -130,7 +130,8 @@ GenerateShofixti (BYTE control)
pCurDesc->data_index = METAL_WORLD; pCurDesc->data_index = METAL_WORLD;
} }
FillOrbits (NUM_PLANETS, &pSolarSysState->PlanetDesc[0], TRUE); FillOrbits (pSolarSysState,
NUM_PLANETS, &pSolarSysState->PlanetDesc[0], TRUE);
break; break;
} }
default: default:
+3 -1
View File
@@ -94,7 +94,9 @@ GenerateSpathi (BYTE control)
PPLANET_DESC pMinPlanet; PPLANET_DESC pMinPlanet;
pMinPlanet = &pSolarSysState->PlanetDesc[0]; 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; pMinPlanet->radius = EARTH_RADIUS * 1150L / 100;
angle = ARCTAN (pMinPlanet->location.x, pMinPlanet->location.y); angle = ARCTAN (pMinPlanet->location.x, pMinPlanet->location.y);
+5 -5
View File
@@ -469,8 +469,8 @@ YellowDistribution (BYTE which_world)
#define SUPERGIANT_GASG_DIST SCALE_RADIUS (33) #define SUPERGIANT_GASG_DIST SCALE_RADIUS (33)
void void
FillOrbits (BYTE NumPlanets, PPLANET_DESC pBaseDesc, BOOLEAN FillOrbits (PSOLARSYS_STATE system,
TypesDefined) BYTE NumPlanets, PPLANET_DESC pBaseDesc, BOOLEAN TypesDefined)
{ /* Generate Planets in orbit around star */ { /* Generate Planets in orbit around star */
BYTE StarColor, PlanetCount, MaxPlanet; BYTE StarColor, PlanetCount, MaxPlanet;
BOOLEAN GeneratingMoons; BOOLEAN GeneratingMoons;
@@ -492,7 +492,7 @@ char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'};
#endif /* DEBUG_ORBITS */ #endif /* DEBUG_ORBITS */
pPD = pBaseDesc; pPD = pBaseDesc;
StarSize = pSolarSysState->SunDesc[0].data_index; StarSize = system->SunDesc[0].data_index;
StarColor = STAR_COLOR (CurStarDescPtr->Type); StarColor = STAR_COLOR (CurStarDescPtr->Type);
if (NumPlanets == (BYTE)~0) if (NumPlanets == (BYTE)~0)
@@ -501,7 +501,7 @@ char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'};
while ((NumPlanets = (BYTE)(LOWORD (TFB_Random()) while ((NumPlanets = (BYTE)(LOWORD (TFB_Random())
% MAX_GENERATED_PLANETS)) == 0) % MAX_GENERATED_PLANETS)) == 0)
; ;
pSolarSysState->SunDesc[0].NumPlanets = NumPlanets; system->SunDesc[0].NumPlanets = NumPlanets;
} }
#ifdef DEBUG_ORBITS #ifdef DEBUG_ORBITS
@@ -510,7 +510,7 @@ char scolor[] = {'B', 'G', 'O', 'R', 'W', 'Y'};
scolor[STAR_COLOR (CurStarDescPtr->Type)], scolor[STAR_COLOR (CurStarDescPtr->Type)],
stype[STAR_TYPE (CurStarDescPtr->Type)]); stype[STAR_TYPE (CurStarDescPtr->Type)]);
#endif /* DEBUG_ORBITS */ #endif /* DEBUG_ORBITS */
GeneratingMoons = (BOOLEAN) (pBaseDesc == pSolarSysState->MoonDesc); GeneratingMoons = (BOOLEAN) (pBaseDesc == system->MoonDesc);
if (GeneratingMoons) if (GeneratingMoons)
MaxPlanet = FIRST_LARGE_ROCKY_WORLD; MaxPlanet = FIRST_LARGE_ROCKY_WORLD;
else else
+2 -2
View File
@@ -203,8 +203,8 @@ extern void DrawSystem (SIZE radius, BOOLEAN IsInnerSystem);
extern void DrawOval (PRECT pRect, BYTE num_off_pixels); extern void DrawOval (PRECT pRect, BYTE num_off_pixels);
extern void DrawFilledOval (PRECT pRect); extern void DrawFilledOval (PRECT pRect);
extern void DoMissions (void); extern void DoMissions (void);
extern void FillOrbits (BYTE NumPlanets, PPLANET_DESC pBaseDesc, BOOLEAN extern void FillOrbits (PSOLARSYS_STATE system,
TypesDefined); BYTE NumPlanets, PPLANET_DESC pBaseDesc, BOOLEAN TypesDefined);
extern void ScanSystem (void); extern void ScanSystem (void);
extern void ChangeSolarSys (void); extern void ChangeSolarSys (void);
extern BOOLEAN DoFlagshipCommands (PMENU_STATE pMS); extern BOOLEAN DoFlagshipCommands (PMENU_STATE pMS);
+12 -10
View File
@@ -62,15 +62,15 @@ static SIZE old_radius;
BYTE draw_sys_flags = DRAW_STARS | DRAW_PLANETS | DRAW_ORBITS BYTE draw_sys_flags = DRAW_STARS | DRAW_PLANETS | DRAW_ORBITS
| DRAW_HYPER_COORDS | GRAB_BKGND; | DRAW_HYPER_COORDS | GRAB_BKGND;
// NB. This function modifies the RNG state.
static void static void
GeneratePlanets (void) GeneratePlanets (PSOLARSYS_STATE system)
{ {
COUNT i; COUNT i;
PPLANET_DESC pCurDesc; PPLANET_DESC planet;
for (i = pSolarSysState->SunDesc[0].NumPlanets, for (i = system->SunDesc[0].NumPlanets,
pCurDesc = &pSolarSysState->PlanetDesc[0]; i; planet = &system->PlanetDesc[0]; i; --i, ++planet)
--i, ++pCurDesc)
{ {
DWORD rand_val; DWORD rand_val;
BYTE byte_val; BYTE byte_val;
@@ -81,7 +81,7 @@ GeneratePlanets (void)
byte_val = LOBYTE (rand_val); byte_val = LOBYTE (rand_val);
num_moons = 0; num_moons = 0;
type = PlanData[pCurDesc->data_index & ~PLANET_SHIELDED].Type; type = PlanData[planet->data_index & ~PLANET_SHIELDED].Type;
switch (PLANSIZE (type)) switch (PLANSIZE (type))
{ {
case LARGE_ROCKY_WORLD: case LARGE_ROCKY_WORLD:
@@ -109,7 +109,7 @@ GeneratePlanets (void)
} }
break; break;
} }
pCurDesc->NumPlanets = num_moons; planet->NumPlanets = num_moons;
} }
} }
@@ -1638,13 +1638,15 @@ GenerateRandomIP (BYTE control)
break; break;
} }
case GENERATE_MOONS: case GENERATE_MOONS:
FillOrbits (pSolarSysState->pBaseDesc->NumPlanets, FillOrbits (pSolarSysState,
pSolarSysState->pBaseDesc->NumPlanets,
&pSolarSysState->MoonDesc[0], FALSE); &pSolarSysState->MoonDesc[0], FALSE);
break; break;
case GENERATE_PLANETS: case GENERATE_PLANETS:
{ {
FillOrbits ((BYTE)~0, &pSolarSysState->PlanetDesc[0], FALSE); FillOrbits (pSolarSysState,
GeneratePlanets(); (BYTE)~0, &pSolarSysState->PlanetDesc[0], FALSE);
GeneratePlanets (pSolarSysState);
break; break;
} }
} }
+2 -1
View File
@@ -254,7 +254,8 @@ GenerateLifeForms (SYSTEM_INFOPTR SysInfoPtr, PCOUNT pwhich_life)
{ {
DWORD old_rand; 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); *pwhich_life = CalcLifeForms (SysInfoPtr, *pwhich_life);
return (TFB_SeedRandom (old_rand)); return (TFB_SeedRandom (old_rand));
} }