Much improved universe data dumper.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1843 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
meep-eep
2005-07-13 21:08:53 +00:00
parent 164f771a6b
commit 6c4ff3284b
8 changed files with 427 additions and 147 deletions
+3 -2
View File
@@ -2086,8 +2086,9 @@ InitCommunication (RESOURCE which_comm)
MEM_HANDLE hOldIndex, hIndex; MEM_HANDLE hOldIndex, hIndex;
LOCDATAPTR LocDataPtr; LOCDATAPTR LocDataPtr;
#ifdef DUMP_STARS #ifdef DEBUG
return 0; if (disableInteractivity)
return 0;
#endif #endif
last_subtitle = NULL; last_subtitle = NULL;
+1 -1
View File
@@ -24,6 +24,7 @@
#include "dummy.h" #include "dummy.h"
#include "coderes.h" #include "coderes.h"
#include "globdata.h"
#include "races.h" #include "races.h"
#include "libs/compiler.h" #include "libs/compiler.h"
@@ -37,7 +38,6 @@ typedef struct
RACE_DESC data _ALIGNED_ANY; RACE_DESC data _ALIGNED_ANY;
} CODERES_STRUCT; } CODERES_STRUCT;
MEM_HANDLE MEM_HANDLE
LoadVidInstance (DWORD res) LoadVidInstance (DWORD res)
{ {
+7
View File
@@ -20,6 +20,7 @@
#include "scan.h" #include "scan.h"
#include "settings.h" #include "settings.h"
#include "setup.h" #include "setup.h"
#include "uqmdebug.h"
#include "libs/graphics/gfx_common.h" #include "libs/graphics/gfx_common.h"
@@ -71,6 +72,12 @@ void
LoadPlanet (BOOLEAN IsDefined) LoadPlanet (BOOLEAN IsDefined)
{ {
STAMP s; STAMP s;
#ifdef DEBUG
if (disableInteractivity)
return;
#endif
LockMutex (GraphicsLock); LockMutex (GraphicsLock);
BatchGraphics (); BatchGraphics ();
+6
View File
@@ -24,6 +24,7 @@
#include "sounds.h" #include "sounds.h"
#include "planets/lander.h" #include "planets/lander.h"
#include "planets/planets.h" #include "planets/planets.h"
#include "uqmdebug.h"
#include "libs/inplib.h" #include "libs/inplib.h"
#include <ctype.h> #include <ctype.h>
@@ -241,6 +242,11 @@ DoDiscoveryReport (SOUND ReadOutSounds)
CONTEXT OldContext; CONTEXT OldContext;
extern void DrawScannedObjects (BOOLEAN Reversed); extern void DrawScannedObjects (BOOLEAN Reversed);
#ifdef DEBUG
if (disableInteractivity)
return;
#endif
if (pMenuState) if (pMenuState)
{ {
old_curs = pMenuState->flash_rect0.corner; old_curs = pMenuState->flash_rect0.corner;
-19
View File
@@ -1891,25 +1891,6 @@ ExploreSolarSys (void)
{ {
SOLARSYS_STATE SolarSysState; SOLARSYS_STATE SolarSysState;
#ifdef DUMP_STARS
{
FILE *out;
// Write the star and planet info to a file in the current directory.
out = fopen("PlanetInfo", "w");
if (out == NULL)
exit(1);
TFB_DEBUG_HALT = 1;
// Disable drawing.
dumpStars(out, DUMP_PLANETS);
fclose(out);
fprintf(stdout, "*** Star dump complete. You can terminate the "
"program now if it does not do so automatically.\n");
exit(0);
// There may be other threads left.
}
#endif
if (CurStarDescPtr == 0) if (CurStarDescPtr == 0)
{ {
POINT universe; POINT universe;
+14
View File
@@ -27,6 +27,7 @@
#include "restart.h" #include "restart.h"
#include "setup.h" #include "setup.h"
#include "starcon.h" #include "starcon.h"
#include "uqmdebug.h"
#include "libs/tasklib.h" #include "libs/tasklib.h"
@@ -138,6 +139,19 @@ while (--ac > 0)
SuspendGameClock (); SuspendGameClock ();
#ifdef DEBUG
if (debugHook != NULL)
{
void (*saveDebugHook) (void);
saveDebugHook = debugHook;
debugHook = NULL;
// No further debugHook callse unless the called
// function resets debugHook.
(*saveDebugHook) ();
continue;
}
#endif
if (!((GLOBAL (CurrentActivity) | NextActivity) & CHECK_LOAD)) if (!((GLOBAL (CurrentActivity) | NextActivity) & CHECK_LOAD))
ZeroVelocityComponents ( ZeroVelocityComponents (
&GLOBAL (velocity) &GLOBAL (velocity)
+335 -94
View File
@@ -27,20 +27,39 @@
#include "gamestr.h" #include "gamestr.h"
#include "gameev.h" #include "gameev.h"
#include "globdata.h" #include "globdata.h"
#include "planets/lifeform.h"
#include "races.h" #include "races.h"
#include "setup.h" #include "setup.h"
#include "state.h" #include "state.h"
#include "libs/mathlib.h"
#include "libs/misc.h" #include "libs/misc.h"
#include <stdio.h> #include <stdio.h>
#include <errno.h>
static void dumpEventCallback (const EVENTPTR eventPtr, void *arg);
static void starRecurse (STAR_DESC *star, void *arg);
static void planetRecurse (STAR_DESC *star, SOLARSYS_STATE *system,
PLANET_DESC *planet, void *arg);
static void moonRecurse (STAR_DESC *star, SOLARSYS_STATE *system,
PLANET_DESC *planet, PLANET_DESC *moon, void *arg);
static void dumpSystemCallback (const STAR_DESC *star,
const SOLARSYS_STATE *system, void *arg);
static void dumpPlanetCallback (const PLANET_DESC *planet, void *arg);
static void dumpMoonCallback (const PLANET_DESC *moon, void *arg);
static void dumpWorld (FILE *out, const PLANET_DESC *world);
static void dumpEventCallback (EVENTPTR eventPtr, void *arg);
static void dumpStarCallback(STAR_DESC *star, void *arg);
static void dumpPlanetCallback (PLANET_DESC *planet, void *arg);
static void dumpPlanetTypeCallback (int index, const PlanetFrame *planet, static void dumpPlanetTypeCallback (int index, const PlanetFrame *planet,
void *arg); void *arg);
BOOLEAN instantMove = FALSE; BOOLEAN instantMove = FALSE;
BOOLEAN disableInteractivity = FALSE;
volatile void (*debugHook) (void) = NULL;
void void
debugKeyPressed (void) debugKeyPressed (void)
@@ -54,14 +73,17 @@ debugKeyPressed (void)
// Informational: // Informational:
// dumpEvents (stderr); // dumpEvents (stderr);
// dumpPlanetTypes(stderr); // dumpPlanetTypes(stderr);
// dumpStars (stderr, DUMP_PLANETS); // debugHook = dumpUniverseToFile;
// Currently dumpStars() does not work when called from here. // This will cause dumpUniverseToFile to be called from the
// It needs to be called from the top of ExploreSolarSys(). // main loop. Calling it from here would give threading
// problems.
// Interactive: // Interactive:
// uio_debugInteractive(stdin, stdout, stderr); // uio_debugInteractive(stdin, stdout, stderr);
} }
////////////////////////////////////////////////////////////////////////////
// Fast forwards to the next event. // Fast forwards to the next event.
// If skipHEE is set, HYPERSPACE_ENCOUNTER_EVENTs are skipped. // If skipHEE is set, HYPERSPACE_ENCOUNTER_EVENTs are skipped.
void void
@@ -158,7 +180,7 @@ eventName (BYTE func_index)
} }
static void static void
dumpEventCallback (EVENTPTR eventPtr, void *arg) dumpEventCallback (const EVENTPTR eventPtr, void *arg)
{ {
FILE *out = (FILE *) arg; FILE *out = (FILE *) arg;
dumpEvent (out, eventPtr); dumpEvent (out, eventPtr);
@@ -167,7 +189,7 @@ dumpEventCallback (EVENTPTR eventPtr, void *arg)
void void
dumpEvent (FILE *out, EVENTPTR eventPtr) dumpEvent (FILE *out, EVENTPTR eventPtr)
{ {
fprintf (out, "%04u/%02u/%02u: %s\n", fprintf (out, "%4u/%02u/%02u: %s\n",
eventPtr->year_index, eventPtr->year_index,
eventPtr->month_index, eventPtr->month_index,
eventPtr->day_index, eventPtr->day_index,
@@ -188,6 +210,7 @@ dumpEvents (FILE *out)
ResumeGameClock (); ResumeGameClock ();
} }
////////////////////////////////////////////////////////////////////////////
// NB: Ship maximum speed and turning rate aren't updated in // NB: Ship maximum speed and turning rate aren't updated in
// HyperSpace/QuasiSpace or in melee. // HyperSpace/QuasiSpace or in melee.
@@ -299,6 +322,8 @@ equipShip (void)
} }
} }
////////////////////////////////////////////////////////////////////////////
void void
showSpheres (void) showSpheres (void)
{ {
@@ -326,6 +351,8 @@ showSpheres (void)
} }
} }
////////////////////////////////////////////////////////////////////////////
void void
forAllStars (void (*callback) (STAR_DESC *, void *), void *arg) forAllStars (void (*callback) (STAR_DESC *, void *), void *arg)
{ {
@@ -335,33 +362,222 @@ forAllStars (void (*callback) (STAR_DESC *, void *), void *arg)
for (i = 0; i < NUM_SOLAR_SYSTEMS; i++) for (i = 0; i < NUM_SOLAR_SYSTEMS; i++)
callback (&starmap_array[i], arg); callback (&starmap_array[i], arg);
} }
typedef struct
{
FILE *out;
UWORD flags;
} DumpStarsArg;
void void
dumpStars (FILE *out, UWORD flags) forAllPlanets (STAR_DESC *star, SOLARSYS_STATE *system, void (*callback) (
STAR_DESC *, SOLARSYS_STATE *, PLANET_DESC *, void *), void *arg)
{ {
DumpStarsArg dumpStarsArg; COUNT i;
dumpStarsArg.out = out;
dumpStarsArg.flags = flags;
forAllStars (dumpStarCallback, (void *) &dumpStarsArg); assert(CurStarDescPtr = star);
assert(pSolarSysState == system);
for (i = 0; i < system->SunDesc[0].NumPlanets; i++)
callback (star, system, &system->PlanetDesc[i], arg);
}
void
forAllMoons (STAR_DESC *star, SOLARSYS_STATE *system, PLANET_DESC *planet,
void (*callback) (STAR_DESC *, SOLARSYS_STATE *, PLANET_DESC *,
PLANET_DESC *, void *), void *arg)
{
COUNT i;
assert(pSolarSysState == system);
assert(system->pBaseDesc == planet);
for (i = 0; i < planet->NumPlanets; i++)
callback (star, system, planet, &system->MoonDesc[i], arg);
}
////////////////////////////////////////////////////////////////////////////
void
UniverseRecurse (UniverseRecurseArg *universeRecurseArg)
{
BOOLEAN clockRunning;
ACTIVITY savedActivity;
if (universeRecurseArg->systemFunc == NULL
&& universeRecurseArg->planetFunc == NULL
&& universeRecurseArg->moonFunc == NULL)
return;
clockRunning = GameClockRunning ();
if (clockRunning)
SuspendGameClock ();
//TFB_DEBUG_HALT = 1;
savedActivity = GLOBAL (CurrentActivity);
disableInteractivity = TRUE;
forAllStars (starRecurse, (void *) universeRecurseArg);
disableInteractivity = FALSE;
GLOBAL (CurrentActivity) = savedActivity;
if (clockRunning)
ResumeGameClock ();
} }
static void static void
dumpStarCallback (STAR_DESC *star, void *arg) starRecurse (STAR_DESC *star, void *arg)
{ {
DumpStarsArg *dumpStarsArg = (DumpStarsArg *) arg; UniverseRecurseArg *universeRecurseArg = (UniverseRecurseArg *) arg;
dumpStar(dumpStarsArg->out, star, dumpStarsArg->flags); SOLARSYS_STATE SolarSysState;
PSOLARSYS_STATE oldPSolarSysState = pSolarSysState;
DWORD oldSeed =
TFB_SeedRandom (MAKE_DWORD (star->star_pt.x, star->star_pt.y));
STAR_DESCPTR oldStarDescPtr = CurStarDescPtr;
CurStarDescPtr = star;
memset (&SolarSysState, 0, sizeof (SolarSysState));
SolarSysState.SunDesc[0].pPrevDesc = 0;
SolarSysState.SunDesc[0].rand_seed = TFB_Random ();
SolarSysState.SunDesc[0].data_index = STAR_TYPE (star->Type);
SolarSysState.SunDesc[0].location.x = 0;
SolarSysState.SunDesc[0].location.y = 0;
//SolarSysState.SunDesc[0].radius = MIN_ZOOM_RADIUS;
SolarSysState.GenFunc = GenerateIP (star->Index);
pSolarSysState = &SolarSysState;
(*pSolarSysState->GenFunc) (GENERATE_PLANETS);
if (universeRecurseArg->systemFunc != NULL)
{
(*universeRecurseArg->systemFunc) (
star, &SolarSysState, universeRecurseArg->arg);
}
if (universeRecurseArg->planetFunc != NULL
|| universeRecurseArg->moonFunc != NULL)
{
forAllPlanets (star, &SolarSysState, planetRecurse,
(void *) universeRecurseArg);
}
pSolarSysState = oldPSolarSysState;
CurStarDescPtr = oldStarDescPtr;
TFB_SeedRandom (oldSeed);
}
static void
planetRecurse (STAR_DESC *star, SOLARSYS_STATE *system,
PLANET_DESC *planet, void *arg)
{
UniverseRecurseArg *universeRecurseArg = (UniverseRecurseArg *) arg;
assert(CurStarDescPtr = star);
assert(pSolarSysState == system);
system->pBaseDesc = planet;
planet->pPrevDesc = &system->SunDesc[0];
if (universeRecurseArg->planetFunc != NULL)
{
system->pOrbitalDesc = planet;
DoPlanetaryAnalysis (&system->SysInfo, planet);
// When GenerateRandomIP is used as GenFunc,
// GENERATE_ORBITAL will also call DoPlanetaryAnalysis,
// but with other GenFuncs this is not guaranteed.
(*system->GenFunc) (GENERATE_ORBITAL);
(*universeRecurseArg->planetFunc) (
planet, universeRecurseArg->arg);
}
if (universeRecurseArg->moonFunc != NULL)
{
DWORD oldSeed = TFB_SeedRandom (planet->rand_seed);
(*system->GenFunc) (GENERATE_MOONS);
forAllMoons (star, system, planet, moonRecurse,
(void *) universeRecurseArg);
TFB_SeedRandom (oldSeed);
}
}
static void
moonRecurse (STAR_DESC *star, SOLARSYS_STATE *system, PLANET_DESC *planet,
PLANET_DESC *moon, void *arg)
{
UniverseRecurseArg *universeRecurseArg = (UniverseRecurseArg *) arg;
assert(CurStarDescPtr = star);
assert(pSolarSysState == system);
assert(system->pBaseDesc == planet);
moon->pPrevDesc = planet;
if (universeRecurseArg->moonFunc != NULL)
{
system->pOrbitalDesc = moon;
DoPlanetaryAnalysis (&system->SysInfo, moon);
// When GenerateRandomIP is used as GenFunc,
// GENERATE_ORBITAL will also call DoPlanetaryAnalysis,
// but with other GenFuncs this is not guaranteed.
(*system->GenFunc) (GENERATE_ORBITAL);
(*universeRecurseArg->moonFunc) (
moon, universeRecurseArg->arg);
}
}
////////////////////////////////////////////////////////////////////////////
typedef struct
{
FILE *out;
} DumpUniverseArg;
void
dumpUniverse (FILE *out)
{
DumpUniverseArg dumpUniverseArg;
UniverseRecurseArg universeRecurseArg;
dumpUniverseArg.out = out;
universeRecurseArg.systemFunc = dumpSystemCallback;
universeRecurseArg.planetFunc = dumpPlanetCallback;
universeRecurseArg.moonFunc = dumpMoonCallback;
universeRecurseArg.arg = (void *) &dumpUniverseArg;
UniverseRecurse (&universeRecurseArg);
} }
void void
dumpStar (FILE *out, const STAR_DESC *star, UWORD flags) dumpUniverseToFile (void)
{
FILE *out;
# define UNIVERSE_DUMP_FILE "PlanetInfo"
out = fopen(UNIVERSE_DUMP_FILE, "w");
if (out == NULL)
{
fprintf(stderr, "Error: Could not open file '%s' for "
"writing: %s\n", UNIVERSE_DUMP_FILE, strerror(errno));
return;
}
dumpUniverse (out);
fclose(out);
fprintf(stdout, "*** Star dump complete. The game may be in an "
"undefined state.\n");
}
static void
dumpSystemCallback (const STAR_DESC *star, const SOLARSYS_STATE *system,
void *arg)
{
FILE *out = ((DumpUniverseArg *) arg)->out;
dumpSystem (out, star, system);
}
void
dumpSystem (FILE *out, const STAR_DESC *star, const SOLARSYS_STATE *system)
{ {
UNICODE name[40]; UNICODE name[40];
UNICODE buf[40]; UNICODE buf[40];
@@ -376,8 +592,8 @@ dumpStar (FILE *out, const STAR_DESC *star, UWORD flags)
star->star_pt.y / 10, star->star_pt.y % 10, star->star_pt.y / 10, star->star_pt.y % 10,
buf, buf,
starPresenceString (star->Index)); starPresenceString (star->Index));
if (flags & DUMP_PLANETS)
dumpPlanets (out, star, flags); (void) system; /* satisfy compiler */
} }
const char * const char *
@@ -527,92 +743,117 @@ starPresenceString (BYTE index)
} }
} }
// Currently, this function only works when called from the top of static void
// ExploreSolarSys(). The state afterwards is undefined. dumpPlanetCallback (const PLANET_DESC *planet, void *arg)
void
forAllPlanets (STAR_DESC *star,
void (*callback) (PLANET_DESC *, void *), void *arg)
{ {
// These two functions were originally static to solarsys.c FILE *out = ((DumpUniverseArg *) arg)->out;
extern void InitSolarSys(void); dumpPlanet (out, planet);
extern void UninitSolarSys(void);
SOLARSYS_STATE solarSysState;
STAR_DESC *oldStarDescPtr;
COUNT i;
oldStarDescPtr = CurStarDescPtr;
CurStarDescPtr = star;
GLOBAL_SIS (log_x) = UNIVERSE_TO_LOGX (CurStarDescPtr->star_pt.x);
GLOBAL_SIS (log_y) = UNIVERSE_TO_LOGY (CurStarDescPtr->star_pt.y);
memset (&solarSysState, 0, sizeof solarSysState);
solarSysState.GenFunc = GenerateIP (CurStarDescPtr->Index);
pSolarSysState = &solarSysState;
GLOBAL (CurrentActivity) = MAKE_WORD (IN_INTERPLANETARY, 0);
SuspendGameClock ();
InitSolarSys ();
for (i = 0; i < pSolarSysState->SunDesc[0].NumPlanets; i++)
callback (&pSolarSysState->PlanetDesc[i], arg);
GLOBAL (autopilot.x) = ~0;
GLOBAL (autopilot.y) = ~0;
GLOBAL (ShipStamp.frame) = 0;
GLOBAL (CurrentActivity) |= START_INTERPLANETARY;
UninitSolarSys ();
pSolarSysState = 0;
CurStarDescPtr = oldStarDescPtr;
} }
typedef struct
{
FILE *out;
UWORD flags;
} DumpPlanetsArg;
void void
dumpPlanets (FILE *out, const STAR_DESC *star, UWORD flags) dumpPlanet (FILE *out, const PLANET_DESC *planet)
{ {
DumpPlanetsArg dumpPlanetsArg; (*pSolarSysState->GenFunc) (GENERATE_NAME);
dumpPlanetsArg.out = out; fprintf (out, "- %-37s %s\n", GLOBAL_SIS (PlanetName),
dumpPlanetsArg.flags = flags; planetTypeString (planet->data_index & ~PLANET_SHIELDED));
dumpWorld (out, planet);
forAllPlanets ((STAR_DESC *) star, dumpPlanetCallback,
(void *) &dumpPlanetsArg);
} }
static void static void
dumpPlanetCallback (PLANET_DESC *planet, void *arg) dumpMoonCallback (const PLANET_DESC *moon, void *arg)
{ {
DumpPlanetsArg *dumpPlanetsArg = (DumpPlanetsArg *) arg; FILE *out = ((DumpUniverseArg *) arg)->out;
dumpPlanet (dumpPlanetsArg->out, planet, dumpPlanetsArg->flags); dumpMoon (out, moon);
} }
void void
dumpPlanet (FILE *out, const PLANET_DESC *planet, UWORD flags) dumpMoon (FILE *out, const PLANET_DESC *moon)
{ {
PLANET_DESC *oldPlanetDesc; const char *typeStr;
oldPlanetDesc = pSolarSysState->pBaseDesc; if (moon->data_index == (BYTE) ~0)
{
// StarBase
typeStr = "StarBase";
}
else
{
typeStr = planetTypeString (moon->data_index & ~PLANET_SHIELDED);
}
fprintf (out, " - Moon %-30c %s\n",
'a' + (moon - &pSolarSysState->MoonDesc[0]), typeStr);
// For now, only the name is printed. Other data may be added later. dumpWorld (out, moon);
pSolarSysState->pBaseDesc = (PLANET_DESC *) planet;
//GetPlanetInfo ();
//(*pSolarSysState->GenFunc) (GENERATE_ORBITAL);
(*pSolarSysState->GenFunc) (GENERATE_NAME);
fprintf (out, "- %-37s %s\n", GLOBAL_SIS (PlanetName),
planetTypeString (planet->data_index));
pSolarSysState->pBaseDesc = oldPlanetDesc;
(void) flags;
} }
static void
dumpWorld (FILE *out, const PLANET_DESC *world)
{
if (world->data_index == (BYTE) ~0)
{
// StarBase
return;
}
fflush(stdout); // XXX temporary
fprintf (out, " Bio: %4d Min: %4d\n",
calculateBioValue (pSolarSysState, world),
calculateMineralValue (pSolarSysState, world));
}
COUNT
calculateBioValue (const SOLARSYS_STATE *system, const PLANET_DESC *world)
{
COUNT result;
COUNT numBio;
COUNT i;
extern const LIFEFORM_DESC CreatureData[];
assert(system->pOrbitalDesc == world);
((SOLARSYS_STATE *) system)->CurNode = (COUNT)~0;
(*system->GenFunc) (GENERATE_LIFE);
numBio = system->CurNode;
result = 0;
for (i = 0; i < numBio; i++)
{
((SOLARSYS_STATE *) system)->CurNode = i;
(*system->GenFunc) (GENERATE_LIFE);
result += BIO_CREDIT_VALUE * LONIBBLE (CreatureData[
system->SysInfo.PlanetInfo.CurType].ValueAndHitPoints);
}
return result;
}
COUNT
calculateMineralValue (const SOLARSYS_STATE *system,
const PLANET_DESC *world)
{
COUNT result;
COUNT numDeposits;
COUNT i;
assert(system->pOrbitalDesc == world);
((SOLARSYS_STATE *) system)->CurNode = (COUNT)~0;
(*system->GenFunc) (GENERATE_MINERAL);
numDeposits = system->CurNode;
result = 0;
for (i = 0; i < numDeposits; i++)
{
((SOLARSYS_STATE *) system)->CurNode = i;
(*system->GenFunc) (GENERATE_MINERAL);
result += HIBYTE (system->SysInfo.PlanetInfo.CurDensity) *
GLOBAL (ElementWorth[ElementCategory (
system->SysInfo.PlanetInfo.CurType)]);
}
return result;
}
////////////////////////////////////////////////////////////////////////////
void void
forAllPlanetTypes (void (*callback) (int, const PlanetFrame *, void *), forAllPlanetTypes (void (*callback) (int, const PlanetFrame *, void *),
void *arg) void *arg)
+61 -31
View File
@@ -24,62 +24,92 @@
#include <stdio.h> #include <stdio.h>
// Define DUMP_STARS to dump a list of stars to ./PlanetInfo. // If set to true, interactive routines that are called (indirectly) in debug
// The list is generated when a new game is started. Normal // functions are a no-op.
// gameplay is not available in this situation. extern BOOLEAN disableInteractivity;
//#define DUMP_STARS
// If a function is assigned to this, it will be called from the main loop.
extern volatile void (*debugHook) (void);
// Called when the debug key (symbol 'Debug' in the keys.cfg) is pressed. // Called when the debug key (symbol 'Debug' in the keys.cfg) is pressed.
extern void debugKeyPressed (void); void debugKeyPressed (void);
// Forward time to the next event. If skipHEE is set, the event named // Forward time to the next event. If skipHEE is set, the event named
// HYPERSPACE_ENCOUNTER_EVENT, which normally occurs every game day, // HYPERSPACE_ENCOUNTER_EVENT, which normally occurs every game day,
// is skipped. // is skipped.
extern void forwardToNextEvent (BOOLEAN skipHEE); void forwardToNextEvent (BOOLEAN skipHEE);
// Generate a list of all events in the event queue. // Generate a list of all events in the event queue.
extern void dumpEvents (FILE *out); void dumpEvents (FILE *out);
// Describe one event. // Describe one event.
extern void dumpEvent (FILE *out, EVENTPTR eventPtr); void dumpEvent (FILE *out, EVENTPTR eventPtr);
// Get the name of one event. // Get the name of one event.
extern const char *eventName (BYTE func_index); const char *eventName (BYTE func_index);
// Give the flagship a decent equipment for debugging. // Give the flagship a decent equipment for debugging.
extern void equipShip (void); void equipShip (void);
// Show all active spheres of influence. // Show all active spheres of influence.
void showSpheres (void); void showSpheres (void);
// Call a function for all stars. // Call a function for all stars.
extern void forAllStars (void (*callBack) (STAR_DESC *, void *), void forAllStars (void (*callback) (STAR_DESC *, void *), void *arg);
void *arg);
// Flags for dumpStar(), dumpStars(), dumpPlanets(), and dumpPlanet().
#define DUMP_PLANETS (1 << 0)
// Describe one star system.
extern void dumpStar(FILE *out, const STAR_DESC *star, UWORD flags);
// Generate a list of all stars.
extern void dumpStars(FILE *out, UWORD flags);
// Get a star color as a string.
extern const char *bodyColorString (BYTE col);
// Get a star type as a string.
extern const char *starTypeString (BYTE type);
// Get a string describing special presence in the star system.
extern const char *starPresenceString (BYTE index);
// Call a function for all planets in a star system. // Call a function for all planets in a star system.
extern void forAllPlanets(STAR_DESC *star, void forAllPlanets (STAR_DESC *star, SOLARSYS_STATE *system,
void (*callback) (PLANET_DESC *, void *), void *arg); void (*callback) (STAR_DESC *, SOLARSYS_STATE *, PLANET_DESC *,
void *), void *arg);
// Call a function for all moons of a planet.
void forAllMoons (STAR_DESC *star, SOLARSYS_STATE *system, PLANET_DESC *planet,
void (*callback) (STAR_DESC *, SOLARSYS_STATE *, PLANET_DESC *,
PLANET_DESC *, void *), void *arg);
// Argument to UniverseRecurse()
typedef struct
{
void (*systemFunc) (const STAR_DESC *star, const SOLARSYS_STATE *system,
void *arg);
void (*planetFunc) (const PLANET_DESC *planet, void *arg);
void (*moonFunc) (const PLANET_DESC *moon, void *arg);
void *arg;
} UniverseRecurseArg;
// Recurse through all systems, planets, and moons in the universe.
void UniverseRecurse (UniverseRecurseArg *universeRecurseArg);
// Describe the entire universe.
void dumpUniverse (FILE *out);
// Describe the entire universe, output to a file "./PlanetInfo".
void dumpUniverseToFile (void);
// Describe one star system.
void dumpSystem (FILE *out, const STAR_DESC *star,
const SOLARSYS_STATE *system);
// Get a star color as a string.
const char *bodyColorString (BYTE col);
// Get a star type as a string.
const char *starTypeString (BYTE type);
// Get a string describing special presence in the star system.
const char *starPresenceString (BYTE index);
// Get a list describing all planets in a star. // Get a list describing all planets in a star.
extern void dumpPlanets (FILE *out, const STAR_DESC *star, UWORD flags); void dumpPlanets (FILE *out, const STAR_DESC *star);
// Describe one planet. // Describe one planet.
extern void dumpPlanet(FILE *out, const PLANET_DESC *planet, UWORD flags); void dumpPlanet(FILE *out, const PLANET_DESC *planet);
// Describe one moon.
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);
// Calculate the total value of all bio on a world.
COUNT calculateBioValue (const SOLARSYS_STATE *system,
const PLANET_DESC *world);
// Call a function for all planet types. // Call a function for all planet types.
extern void forAllPlanetTypes (void (*callBack) (int, const PlanetFrame *, void forAllPlanetTypes (void (*callBack) (int, const PlanetFrame *,
void *), void *arg); void *), void *arg);
// Describe one planet type. // Describe one planet type.
extern void dumpPlanetType(FILE *out, int index, const PlanetFrame *planetFrame); void dumpPlanetType(FILE *out, int index, const PlanetFrame *planetFrame);
// Generate a list of all planet types. // Generate a list of all planet types.
extern void dumpPlanetTypes(FILE *out); void dumpPlanetTypes(FILE *out);
// Get a string describing a planet type. // Get a string describing a planet type.
const char *planetTypeString (int typeIndex); const char *planetTypeString (int typeIndex);
// Get a string describing the size of a type of planet. // Get a string describing the size of a type of planet.