Added a routine for displaying the (active) spheres of influence.

Some cleanups according to our coding standards.


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1402 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
meep-eep
2004-08-02 13:43:26 +00:00
parent 2010ebdf17
commit 730970b08e
2 changed files with 53 additions and 12 deletions
+48 -10
View File
@@ -36,6 +36,7 @@ debugKeyPressed (void)
// State modifying: // State modifying:
equipShip (); equipShip ();
instantMove = !instantMove; instantMove = !instantMove;
showSpheres ();
// forwardToNextEvent (TRUE); // forwardToNextEvent (TRUE);
// Informational: // Informational:
@@ -286,7 +287,35 @@ equipShip (void)
} }
void void
forAllStars(void (*callback) (STAR_DESC *, void *), void *arg) { showSpheres (void)
{
HSTARSHIP hStarShip, hNextShip;
for (hStarShip = GetHeadLink (&GLOBAL (avail_race_q));
hStarShip != NULL; hStarShip = hNextShip)
{
EXTENDED_SHIP_FRAGMENTPTR StarShipPtr;
StarShipPtr = (EXTENDED_SHIP_FRAGMENTPTR) LockStarShip (
&GLOBAL (avail_race_q), hStarShip);
hNextShip = _GetSuccLink (StarShipPtr);
if ((StarShipPtr->ShipInfo.actual_strength != (COUNT) ~0) &&
(StarShipPtr->ShipInfo.known_strength !=
StarShipPtr->ShipInfo.actual_strength))
{
StarShipPtr->ShipInfo.known_strength =
StarShipPtr->ShipInfo.actual_strength;
StarShipPtr->ShipInfo.known_loc = StarShipPtr->ShipInfo.loc;
}
UnlockStarShip (&GLOBAL (avail_race_q), hStarShip);
}
}
void
forAllStars (void (*callback) (STAR_DESC *, void *), void *arg)
{
int i; int i;
extern STAR_DESC starmap_array[]; extern STAR_DESC starmap_array[];
@@ -294,13 +323,15 @@ forAllStars(void (*callback) (STAR_DESC *, void *), void *arg) {
callback (&starmap_array[i], arg); callback (&starmap_array[i], arg);
} }
typedef struct { typedef struct
{
FILE *out; FILE *out;
UWORD flags; UWORD flags;
} DumpStarsArg; } DumpStarsArg;
void void
dumpStars(FILE *out, UWORD flags) { dumpStars (FILE *out, UWORD flags)
{
DumpStarsArg dumpStarsArg; DumpStarsArg dumpStarsArg;
dumpStarsArg.out = out; dumpStarsArg.out = out;
dumpStarsArg.flags = flags; dumpStarsArg.flags = flags;
@@ -309,14 +340,16 @@ dumpStars(FILE *out, UWORD flags) {
} }
static void static void
dumpStarCallback(STAR_DESC *star, void *arg) { dumpStarCallback (STAR_DESC *star, void *arg)
{
DumpStarsArg *dumpStarsArg = (DumpStarsArg *) arg; DumpStarsArg *dumpStarsArg = (DumpStarsArg *) arg;
dumpStar(dumpStarsArg->out, star, dumpStarsArg->flags); dumpStar(dumpStarsArg->out, star, dumpStarsArg->flags);
} }
void void
dumpStar(FILE *out, const STAR_DESC *star, UWORD flags) { dumpStar (FILE *out, const STAR_DESC *star, UWORD flags)
{
UNICODE name[40]; UNICODE name[40];
UNICODE buf[40]; UNICODE buf[40];
@@ -335,7 +368,8 @@ dumpStar(FILE *out, const STAR_DESC *star, UWORD flags) {
} }
const char * const char *
starColorString (BYTE col) { starColorString (BYTE col)
{
switch (col) { switch (col) {
case BLUE_BODY: case BLUE_BODY:
return "blue"; return "blue";
@@ -356,7 +390,8 @@ starColorString (BYTE col) {
} }
const char * const char *
starTypeString (BYTE type) { starTypeString (BYTE type)
{
switch (type) { switch (type) {
case DWARF_STAR: case DWARF_STAR:
return "dwarf"; return "dwarf";
@@ -371,7 +406,8 @@ starTypeString (BYTE type) {
} }
const char * const char *
starPresenceString (BYTE index) { starPresenceString (BYTE index)
{
switch (index) { switch (index) {
case 0: case 0:
// nothing // nothing
@@ -514,13 +550,15 @@ forAllPlanets(STAR_DESC *star,
CurStarDescPtr = oldStarDescPtr; CurStarDescPtr = oldStarDescPtr;
} }
typedef struct { typedef struct
{
FILE *out; FILE *out;
UWORD flags; UWORD flags;
} DumpPlanetsArg; } DumpPlanetsArg;
void void
dumpPlanets (FILE *out, const STAR_DESC *star, UWORD flags) { dumpPlanets (FILE *out, const STAR_DESC *star, UWORD flags)
{
DumpPlanetsArg dumpPlanetsArg; DumpPlanetsArg dumpPlanetsArg;
dumpPlanetsArg.out = out; dumpPlanetsArg.out = out;
dumpPlanetsArg.flags = flags; dumpPlanetsArg.flags = flags;
+3
View File
@@ -34,6 +34,9 @@ extern 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); extern void equipShip (void);
// Show all active spheres of influence.
void showSpheres (void);
// Call a function for all stars. // Call a function for all stars.
extern void forAllStars (void (*callBack) (STAR_DESC *, void *), extern void forAllStars (void (*callBack) (STAR_DESC *, void *),
void *arg); void *arg);