From 29a58df162de7801ef6ca19c0eb8757a3fe06b73 Mon Sep 17 00:00:00 2001 From: meep-eep Date: Mon, 22 Aug 2005 22:51:42 +0000 Subject: [PATCH] Some additions. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1858 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/uqmdebug.c | 67 +++++++++++++++++++++++++++++++++++++- sc2/src/sc2code/uqmdebug.h | 6 ++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/sc2/src/sc2code/uqmdebug.c b/sc2/src/sc2code/uqmdebug.c index edd273567..71b084b64 100644 --- a/sc2/src/sc2code/uqmdebug.c +++ b/sc2/src/sc2code/uqmdebug.c @@ -566,6 +566,8 @@ dumpUniverseToFile (void) fprintf(stdout, "*** Star dump complete. The game may be in an " "undefined state.\n"); + // Data generation may have changed the game state, + // in particular for special planet generation. } static void @@ -792,6 +794,8 @@ dumpMoon (FILE *out, const PLANET_DESC *moon) static void dumpWorld (FILE *out, const PLANET_DESC *world) { + PLANET_INFO *info; + if (world->data_index == (BYTE) ~0) { // StarBase return; @@ -802,6 +806,19 @@ dumpWorld (FILE *out, const PLANET_DESC *world) return; } + info = &pSolarSysState->SysInfo.PlanetInfo; + fprintf(out, " AxialTilt: %d\n", info->AxialTilt); + fprintf(out, " Tectonics: %d\n", info->Tectonics); + fprintf(out, " Weather: %d\n", info->Weather); + fprintf(out, " Density: %d\n", info->PlanetDensity); + fprintf(out, " Radius: %d\n", info->PlanetRadius); + fprintf(out, " Gravity: %d\n", info->SurfaceGravity); + fprintf(out, " Temp: %d\n", info->SurfaceTemperature); + fprintf(out, " Day: %d\n", info->RotationPeriod); + fprintf(out, " Atmosphere: %d\n", info->AtmoDensity); + fprintf(out, " LifeChance: %d\n", info->LifeChance); + fprintf(out, " DistToSun: %d\n", info->PlanetToSunDist); + if (world->data_index & PLANET_SHIELDED) { // Slave-shielded planet return; @@ -818,7 +835,6 @@ calculateBioValue (const SOLARSYS_STATE *system, const PLANET_DESC *world) COUNT result; COUNT numBio; COUNT i; - extern const LIFEFORM_DESC CreatureData[]; assert(system->pOrbitalDesc == world); @@ -837,6 +853,30 @@ calculateBioValue (const SOLARSYS_STATE *system, const PLANET_DESC *world) return result; } +void +generateBioIndex(const SOLARSYS_STATE *system, + const PLANET_DESC *world, COUNT bio[]) +{ + COUNT numBio; + COUNT i; + + assert(system->pOrbitalDesc == world); + + ((SOLARSYS_STATE *) system)->CurNode = (COUNT)~0; + (*system->GenFunc) (GENERATE_LIFE); + numBio = system->CurNode; + + for (i = 0; i < NUM_CREATURE_TYPES + NUM_SPECIAL_CREATURE_TYPES; i++) + bio[i] = 0; + + for (i = 0; i < numBio; i++) + { + ((SOLARSYS_STATE *) system)->CurNode = i; + (*system->GenFunc) (GENERATE_LIFE); + bio[system->SysInfo.PlanetInfo.CurType]++; + } +} + COUNT calculateMineralValue (const SOLARSYS_STATE *system, const PLANET_DESC *world) @@ -863,6 +903,31 @@ calculateMineralValue (const SOLARSYS_STATE *system, return result; } +void +generateMineralIndex(const SOLARSYS_STATE *system, + const PLANET_DESC *world, COUNT minerals[]) +{ + COUNT numDeposits; + COUNT i; + + assert(system->pOrbitalDesc == world); + + ((SOLARSYS_STATE *) system)->CurNode = (COUNT)~0; + (*system->GenFunc) (GENERATE_MINERAL); + numDeposits = system->CurNode; + + for (i = 0; i < NUM_ELEMENT_CATEGORIES; i++) + minerals[i] = 0; + + for (i = 0; i < numDeposits; i++) + { + ((SOLARSYS_STATE *) system)->CurNode = i; + (*system->GenFunc) (GENERATE_MINERAL); + minerals[ElementCategory(system->SysInfo.PlanetInfo.CurType)] += + HIBYTE (system->SysInfo.PlanetInfo.CurDensity); + } +} + //////////////////////////////////////////////////////////////////////////// void diff --git a/sc2/src/sc2code/uqmdebug.h b/sc2/src/sc2code/uqmdebug.h index 432203c62..3e69e10b3 100644 --- a/sc2/src/sc2code/uqmdebug.h +++ b/sc2/src/sc2code/uqmdebug.h @@ -98,9 +98,15 @@ void dumpMoon (FILE *out, const PLANET_DESC *moon); // Calculate the total value of all minerals on a world. COUNT calculateMineralValue (const SOLARSYS_STATE *system, const PLANET_DESC *world); +// Determine how much of each mineral type is present on a world +void generateMineralIndex(const SOLARSYS_STATE *system, + const PLANET_DESC *world, COUNT minerals[]); // Calculate the total value of all bio on a world. COUNT calculateBioValue (const SOLARSYS_STATE *system, const PLANET_DESC *world); +// Determine how much of each mineral type is present on a world +void generateBioIndex(const SOLARSYS_STATE *system, + const PLANET_DESC *world, COUNT bio[]); // Call a function for all planet types.