Added code to dump planet types.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1429 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -31,6 +31,8 @@ listed below:
|
|||||||
day, are skipped.
|
day, are skipped.
|
||||||
- the function dumpEvents()
|
- the function dumpEvents()
|
||||||
Outputs information on all scheduled events to a FILE.
|
Outputs information on all scheduled events to a FILE.
|
||||||
|
- the function dumpPlanetTypes()
|
||||||
|
Outputs information on all planet types to a FILE.
|
||||||
- the function dumpStars()
|
- the function dumpStars()
|
||||||
Outputs information on all stars to a FILE.
|
Outputs information on all stars to a FILE.
|
||||||
With the 'flags' variable, the amount of detail can be specified.
|
With the 'flags' variable, the amount of detail can be specified.
|
||||||
|
|||||||
+226
-4
@@ -27,6 +27,8 @@
|
|||||||
static void dumpEventCallback (EVENTPTR eventPtr, void *arg);
|
static void dumpEventCallback (EVENTPTR eventPtr, void *arg);
|
||||||
static void dumpStarCallback(STAR_DESC *star, void *arg);
|
static void dumpStarCallback(STAR_DESC *star, void *arg);
|
||||||
static void dumpPlanetCallback (PLANET_DESC *planet, void *arg);
|
static void dumpPlanetCallback (PLANET_DESC *planet, void *arg);
|
||||||
|
static void dumpPlanetTypeCallback (int index, const PlanetFrame *planet,
|
||||||
|
void *arg);
|
||||||
|
|
||||||
BOOLEAN instantMove = FALSE;
|
BOOLEAN instantMove = FALSE;
|
||||||
|
|
||||||
@@ -41,7 +43,8 @@ debugKeyPressed (void)
|
|||||||
|
|
||||||
// Informational:
|
// Informational:
|
||||||
// dumpEvents (stderr);
|
// dumpEvents (stderr);
|
||||||
// dumpStars (stdout, DUMP_PLANETS);
|
// dumpPlanetTypes(stderr);
|
||||||
|
// dumpStars (stderr, DUMP_PLANETS);
|
||||||
// Currently dumpStars() does not work when called from here.
|
// Currently dumpStars() does not work when called from here.
|
||||||
// It needs to be called from the top of ExploreSolarSys().
|
// It needs to be called from the top of ExploreSolarSys().
|
||||||
|
|
||||||
@@ -355,7 +358,7 @@ dumpStar (FILE *out, const STAR_DESC *star, UWORD flags)
|
|||||||
|
|
||||||
GetClusterName ((STAR_DESCPTR) star, name);
|
GetClusterName ((STAR_DESCPTR) star, name);
|
||||||
snprintf (buf, sizeof buf, "%s %s",
|
snprintf (buf, sizeof buf, "%s %s",
|
||||||
starColorString (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\n",
|
||||||
name,
|
name,
|
||||||
@@ -368,7 +371,7 @@ dumpStar (FILE *out, const STAR_DESC *star, UWORD flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
starColorString (BYTE col)
|
bodyColorString (BYTE col)
|
||||||
{
|
{
|
||||||
switch (col) {
|
switch (col) {
|
||||||
case BLUE_BODY:
|
case BLUE_BODY:
|
||||||
@@ -383,6 +386,12 @@ starColorString (BYTE col)
|
|||||||
return "white";
|
return "white";
|
||||||
case YELLOW_BODY:
|
case YELLOW_BODY:
|
||||||
return "yellow";
|
return "yellow";
|
||||||
|
case CYAN_BODY:
|
||||||
|
return "cyan";
|
||||||
|
case PURPLE_BODY:
|
||||||
|
return "purple";
|
||||||
|
case VIOLET_BODY:
|
||||||
|
return "violet";
|
||||||
default:
|
default:
|
||||||
// Should not happen
|
// Should not happen
|
||||||
return "???";
|
return "???";
|
||||||
@@ -584,13 +593,226 @@ dumpPlanet (FILE *out, const PLANET_DESC *planet, UWORD flags)
|
|||||||
// For now, only the name is printed. Other data may be added later.
|
// For now, only the name is printed. Other data may be added later.
|
||||||
pSolarSysState->pBaseDesc = (PLANET_DESC *) planet;
|
pSolarSysState->pBaseDesc = (PLANET_DESC *) planet;
|
||||||
(*pSolarSysState->GenFunc) (GENERATE_NAME);
|
(*pSolarSysState->GenFunc) (GENERATE_NAME);
|
||||||
fprintf (out, "- %s\n", GLOBAL_SIS (PlanetName));
|
fprintf (out, "- %-37s %s\n", GLOBAL_SIS (PlanetName),
|
||||||
|
planetTypeString (planet->data_index));
|
||||||
|
|
||||||
pSolarSysState->pBaseDesc = oldPlanetDesc;
|
pSolarSysState->pBaseDesc = oldPlanetDesc;
|
||||||
|
|
||||||
(void) flags;
|
(void) flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
forAllPlanetTypes (void (*callback) (int, const PlanetFrame *, void *),
|
||||||
|
void *arg)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
extern const PlanetFrame planet_array[];
|
||||||
|
|
||||||
|
for (i = 0; i < NUMBER_OF_PLANET_TYPES; i++)
|
||||||
|
callback (i, &planet_array[i], arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
FILE *out;
|
||||||
|
} DumpPlanetTypesArg;
|
||||||
|
|
||||||
|
void
|
||||||
|
dumpPlanetTypes (FILE *out)
|
||||||
|
{
|
||||||
|
DumpPlanetTypesArg dumpPlanetTypesArg;
|
||||||
|
dumpPlanetTypesArg.out = out;
|
||||||
|
|
||||||
|
forAllPlanetTypes (dumpPlanetTypeCallback, (void *) &dumpPlanetTypesArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dumpPlanetTypeCallback (int index, const PlanetFrame *planetType, void *arg)
|
||||||
|
{
|
||||||
|
DumpPlanetTypesArg *dumpPlanetTypesArg = (DumpPlanetTypesArg *) arg;
|
||||||
|
|
||||||
|
dumpPlanetType(dumpPlanetTypesArg->out, index, planetType);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dumpPlanetType (FILE *out, int index, const PlanetFrame *planetType)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
fprintf (out,
|
||||||
|
"%s\n"
|
||||||
|
"\tType: %s\n"
|
||||||
|
"\tColor: %s\n"
|
||||||
|
"\tSurface generation algoritm: %s\n"
|
||||||
|
"\tTectonics: %s\n"
|
||||||
|
"\tAtmosphere: %s\n"
|
||||||
|
"\tDensity: %s\n"
|
||||||
|
"\tElements:\n",
|
||||||
|
planetTypeString (index),
|
||||||
|
worldSizeString (PLANSIZE (planetType->Type)),
|
||||||
|
bodyColorString (PLANCOLOR (planetType->Type)),
|
||||||
|
worldGenAlgoString (PLANALGO (planetType->Type)),
|
||||||
|
tectonicsString (planetType->BaseTectonics),
|
||||||
|
atmosphereString (HINIBBLE (planetType->AtmoAndDensity)),
|
||||||
|
densityString (LONIBBLE (planetType->AtmoAndDensity))
|
||||||
|
);
|
||||||
|
for (i = 0; i < NUM_USEFUL_ELEMENTS; i++)
|
||||||
|
{
|
||||||
|
const ElementEntry *entry;
|
||||||
|
entry = &planetType->UsefulElements[i];
|
||||||
|
if (entry->Density == 0)
|
||||||
|
continue;
|
||||||
|
fprintf(out, "\t\t0 to %d %s-quality (+%d) deposits of %s (%s)\n",
|
||||||
|
DEPOSIT_QUANTITY (entry->Density),
|
||||||
|
depositQualityString (DEPOSIT_QUALITY (entry->Density)),
|
||||||
|
DEPOSIT_QUALITY (entry->Density) * 5,
|
||||||
|
GAME_STRING (ELEMENTS_STRING_BASE + entry->ElementType),
|
||||||
|
GAME_STRING (CARGO_STRING_BASE + 2 + ElementCategory (
|
||||||
|
entry->ElementType))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
fprintf (out, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
planetTypeString (int typeIndex)
|
||||||
|
{
|
||||||
|
static UNICODE typeStr[40];
|
||||||
|
|
||||||
|
if (typeIndex >= FIRST_GAS_GIANT)
|
||||||
|
{
|
||||||
|
// "Gas Giant"
|
||||||
|
snprintf(typeStr, sizeof typeStr, "%s",
|
||||||
|
GAME_STRING (SCAN_STRING_BASE + 4 + 51));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// "<type> World" (eg. "Water World")
|
||||||
|
snprintf(typeStr, sizeof typeStr, "%s %s",
|
||||||
|
GAME_STRING (SCAN_STRING_BASE + 4 + typeIndex),
|
||||||
|
GAME_STRING (SCAN_STRING_BASE + 4 + 50));
|
||||||
|
}
|
||||||
|
return typeStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// size is what you get from PLANSIZE (planetFrame.Type)
|
||||||
|
const char *
|
||||||
|
worldSizeString (BYTE size)
|
||||||
|
{
|
||||||
|
switch (size)
|
||||||
|
{
|
||||||
|
case SMALL_ROCKY_WORLD:
|
||||||
|
return "small rocky world";
|
||||||
|
case LARGE_ROCKY_WORLD:
|
||||||
|
return "large rocky world";
|
||||||
|
case GAS_GIANT:
|
||||||
|
return "gas giant";
|
||||||
|
default:
|
||||||
|
// Should not happen
|
||||||
|
return "???";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// algo is what you get from PLANALGO (planetFrame.Type)
|
||||||
|
const char *
|
||||||
|
worldGenAlgoString (BYTE algo)
|
||||||
|
{
|
||||||
|
switch (algo)
|
||||||
|
{
|
||||||
|
case TOPO_ALGO:
|
||||||
|
return "TOPO_ALGO";
|
||||||
|
case CRATERED_ALGO:
|
||||||
|
return "CRATERED_ALGO";
|
||||||
|
case GAS_GIANT_ALGO:
|
||||||
|
return "GAS_GIANT_ALGO";
|
||||||
|
default:
|
||||||
|
// Should not happen
|
||||||
|
return "???";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// tectonics is what you get from planetFrame.BaseTechtonics
|
||||||
|
// not reentrant
|
||||||
|
const char *
|
||||||
|
tectonicsString (BYTE tectonics)
|
||||||
|
{
|
||||||
|
static char buf[sizeof "-127"];
|
||||||
|
switch (tectonics)
|
||||||
|
{
|
||||||
|
case NO_TECTONICS:
|
||||||
|
return "none";
|
||||||
|
case LOW_TECTONICS:
|
||||||
|
return "low";
|
||||||
|
case MED_TECTONICS:
|
||||||
|
return "medium";
|
||||||
|
case HIGH_TECTONICS:
|
||||||
|
return "high";
|
||||||
|
case SUPER_TECTONICS:
|
||||||
|
return "super";
|
||||||
|
default:
|
||||||
|
snprintf (buf, sizeof buf, "%d", tectonics);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// atmosphere is what you get from HINIBBLE (planetFrame.AtmoAndDensity)
|
||||||
|
const char *
|
||||||
|
atmosphereString (BYTE atmosphere)
|
||||||
|
{
|
||||||
|
switch (atmosphere)
|
||||||
|
{
|
||||||
|
case LIGHT:
|
||||||
|
return "thin";
|
||||||
|
case MEDIUM:
|
||||||
|
return "normal";
|
||||||
|
case HEAVY:
|
||||||
|
return "thick";
|
||||||
|
default:
|
||||||
|
return "super thick";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// density is what you get from LONIBBLE (planetFrame.AtmoAndDensity)
|
||||||
|
const char *
|
||||||
|
densityString (BYTE density)
|
||||||
|
{
|
||||||
|
switch (density)
|
||||||
|
{
|
||||||
|
case GAS_DENSITY:
|
||||||
|
return "gaseous";
|
||||||
|
case LIGHT_DENSITY:
|
||||||
|
return "light";
|
||||||
|
case LOW_DENSITY:
|
||||||
|
return "low";
|
||||||
|
case NORMAL_DENSITY:
|
||||||
|
return "normal";
|
||||||
|
case HIGH_DENSITY:
|
||||||
|
return "high";
|
||||||
|
case SUPER_DENSITY:
|
||||||
|
return "super high";
|
||||||
|
default:
|
||||||
|
// Should not happen
|
||||||
|
return "???";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// quality is what you get from DEPOSIT_QUALITY (elementEntry.Density)
|
||||||
|
const char *
|
||||||
|
depositQualityString (BYTE quality)
|
||||||
|
{
|
||||||
|
switch (quality)
|
||||||
|
{
|
||||||
|
case LIGHT:
|
||||||
|
return "low";
|
||||||
|
case MEDIUM:
|
||||||
|
return "medium";
|
||||||
|
case HEAVY:
|
||||||
|
return "high";
|
||||||
|
default:
|
||||||
|
// Should not happen
|
||||||
|
return "???";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ extern void dumpStar(FILE *out, const STAR_DESC *star, UWORD flags);
|
|||||||
// Generate a list of all stars.
|
// Generate a list of all stars.
|
||||||
extern void dumpStars(FILE *out, UWORD flags);
|
extern void dumpStars(FILE *out, UWORD flags);
|
||||||
// Get a star color as a string.
|
// Get a star color as a string.
|
||||||
extern const char *starColorString (BYTE col);
|
extern const char *bodyColorString (BYTE col);
|
||||||
// Get a star type as a string.
|
// Get a star type as a string.
|
||||||
extern const char *starTypeString (BYTE type);
|
extern const char *starTypeString (BYTE type);
|
||||||
// Get a string describing special presence in the star system.
|
// Get a string describing special presence in the star system.
|
||||||
@@ -60,6 +60,32 @@ extern void dumpPlanets (FILE *out, const STAR_DESC *star, UWORD flags);
|
|||||||
// Describe one planet.
|
// Describe one planet.
|
||||||
extern void dumpPlanet(FILE *out, const PLANET_DESC *planet, UWORD flags);
|
extern void dumpPlanet(FILE *out, const PLANET_DESC *planet, UWORD flags);
|
||||||
|
|
||||||
|
// Call a function for all planet types.
|
||||||
|
extern void forAllPlanetTypes (void (*callBack) (int, const PlanetFrame *,
|
||||||
|
void *), void *arg);
|
||||||
|
// Describe one planet type.
|
||||||
|
extern void dumpPlanetType(FILE *out, int index, const PlanetFrame *planetFrame);
|
||||||
|
// Generate a list of all planet types.
|
||||||
|
extern void dumpPlanetTypes(FILE *out);
|
||||||
|
// Get a string describing a planet type.
|
||||||
|
const char *planetTypeString (int typeIndex);
|
||||||
|
// Get a string describing the size of a type of planet.
|
||||||
|
const char *worldSizeString (BYTE size);
|
||||||
|
// Get a string describing a planet type map generation algoritm.
|
||||||
|
const char *worldGenAlgoString (BYTE algo);
|
||||||
|
// Get a string describing the severity of a tectonics on a type of planet.
|
||||||
|
const char *tectonicsString (BYTE tectonics);
|
||||||
|
// Get a string describing the atmospheric pressure on a type of planet.
|
||||||
|
const char *atmosphereString (BYTE atmosphere);
|
||||||
|
// Get a string describing the density of a type of planet.
|
||||||
|
const char *densityString (BYTE density);
|
||||||
|
|
||||||
|
// Get a string describing the quality of a deposit.
|
||||||
|
const char *depositQualityString (BYTE quality);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Move instantly across hyperspace/quasispace.
|
// Move instantly across hyperspace/quasispace.
|
||||||
extern BOOLEAN instantMove;
|
extern BOOLEAN instantMove;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user