diff --git a/sc2/src/uqm/planets/generate.h b/sc2/src/uqm/planets/generate.h index 13de8f394..14d212ba6 100644 --- a/sc2/src/uqm/planets/generate.h +++ b/sc2/src/uqm/planets/generate.h @@ -43,8 +43,6 @@ typedef struct GenerateFunctions GenerateFunctions; * solarSys->genFuncs->..., but use a function for this, which first * checks for solar system dependent handlers, and if this does not exist, * or returns false, calls the default function. - * - use isNodeRetrieved, setNodeRetrieved, and setNodeNotRetrieved instead - * of manually messing with bit shifts, etc. */ // Any of these functions returning true means that the action has been diff --git a/sc2/src/uqm/planets/generate/genand.c b/sc2/src/uqm/planets/generate/genand.c index 279d268f2..07264a616 100644 --- a/sc2/src/uqm/planets/generate/genand.c +++ b/sc2/src/uqm/planets/generate/genand.c @@ -19,6 +19,7 @@ #include "genall.h" #include "../lander.h" #include "../planets.h" +#include "../scan.h" #include "../../globdata.h" #include "../../nameref.h" #include "../../resinst.h" @@ -71,7 +72,8 @@ GenerateAndrosynth_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world { if (matchWorld (solarSys, world, 1, MATCH_PLANET)) { - UWORD retval; + COUNT i; + COUNT visits = 0; LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); solarSys->PlanetSideFrame[1] = @@ -79,25 +81,28 @@ GenerateAndrosynth_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world solarSys->SysInfo.PlanetInfo.DiscoveryString = CaptureStringTable ( LoadStringTable (ANDROSYNTH_RUINS_STRTAB)); - retval = HIWORD ( - solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN]); - while (retval) + // Androsynth ruins are a special case. The DiscoveryString contains + // several lander reports which form a story. Each report is given + // when the player collides with a new city ruin. Ruins previously + // visited are marked in the upper 16 bits of ScanRetrieveMask, and + // the lower bits are cleared to keep the ruin nodes on the map. + for (i = 16; i < 32; ++i) { - if (retval & 1) - { - solarSys->SysInfo.PlanetInfo.DiscoveryString = - SetRelStringTableIndex ( - solarSys->SysInfo.PlanetInfo.DiscoveryString, 1); - if (GetStringTableIndex ( - solarSys->SysInfo.PlanetInfo.DiscoveryString) == 0) - { - DestroyStringTable (ReleaseStringTable ( - solarSys->SysInfo.PlanetInfo.DiscoveryString)); - solarSys->SysInfo.PlanetInfo.DiscoveryString = 0; - } - } - - retval >>= 1; + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i)) + ++visits; + } + if (visits >= GetStringTableCount ( + solarSys->SysInfo.PlanetInfo.DiscoveryString)) + { // All the reports were already given + DestroyStringTable (ReleaseStringTable ( + solarSys->SysInfo.PlanetInfo.DiscoveryString)); + solarSys->SysInfo.PlanetInfo.DiscoveryString = 0; + } + else + { // Advance the report sequence to the first unread + solarSys->SysInfo.PlanetInfo.DiscoveryString = + SetRelStringTableIndex ( + solarSys->SysInfo.PlanetInfo.DiscoveryString, visits); } } @@ -139,23 +144,24 @@ GenerateAndrosynth_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, solarSys->SysInfo.PlanetInfo.CurType = 0; solarSys->SysInfo.PlanetInfo.CurDensity = 0; - if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << i)) + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i)) { - solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - &= ~(1L << i); - if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << (i + 16)))) + // Retrieval status is cleared to keep the node on the map + setNodeNotRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i); + // Ruins previously visited are marked in the upper 16 bits + if (!isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, + i + 16)) { SET_GAME_STATE (PLANETARY_CHANGE, 1); - solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - |= (1L << (i + 16)); + setNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, + i + 16); if (solarSys->SysInfo.PlanetInfo.DiscoveryString) { UnbatchGraphics (); DoDiscoveryReport (MenuSounds); BatchGraphics (); + // Advance to the next report solarSys->SysInfo.PlanetInfo.DiscoveryString = SetRelStringTableIndex ( solarSys->SysInfo.PlanetInfo.DiscoveryString, diff --git a/sc2/src/uqm/planets/generate/genburv.c b/sc2/src/uqm/planets/generate/genburv.c index efc8a32c9..673844f30 100644 --- a/sc2/src/uqm/planets/generate/genburv.c +++ b/sc2/src/uqm/planets/generate/genburv.c @@ -18,6 +18,7 @@ #include "genall.h" #include "../planets.h" +#include "../scan.h" #include "../../globdata.h" #include "../../nameref.h" #include "../../resinst.h" @@ -179,8 +180,7 @@ GenerateBurvixese_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; solarSys->SysInfo.PlanetInfo.CurDensity = 0; solarSys->SysInfo.PlanetInfo.CurType = 0; - if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (!isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0) && *whichNode == (COUNT)~0) { *whichNode = 1; @@ -188,8 +188,7 @@ GenerateBurvixese_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, else { *whichNode = 0; - if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { SET_GAME_STATE (BURVIXESE_BROADCASTERS, 1); SET_GAME_STATE (BURV_BROADCASTERS_ON_SHIP, 1); diff --git a/sc2/src/uqm/planets/generate/gendru.c b/sc2/src/uqm/planets/generate/gendru.c index cd5e02751..844edb5f2 100644 --- a/sc2/src/uqm/planets/generate/gendru.c +++ b/sc2/src/uqm/planets/generate/gendru.c @@ -19,6 +19,7 @@ #include "genall.h" #include "../lander.h" #include "../planets.h" +#include "../scan.h" #include "../../build.h" #include "../../comm.h" #include "../../globdata.h" @@ -149,11 +150,11 @@ GenerateDruuge_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, else solarSys->SysInfo.PlanetInfo.CurType = 1; solarSys->SysInfo.PlanetInfo.CurDensity = 0; - if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << i)) + + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i)) { - solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - &= ~(1L << i); + // Retrieval status is cleared to keep the node on the map + setNodeNotRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i); if (!GET_GAME_STATE (ROSY_SPHERE)) { @@ -163,6 +164,7 @@ GenerateDruuge_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, SET_GAME_STATE (ROSY_SPHERE_ON_SHIP, 1); } } + if (i >= *whichNode) break; } diff --git a/sc2/src/uqm/planets/generate/genmyc.c b/sc2/src/uqm/planets/generate/genmyc.c index 150773e4c..7b21480a0 100644 --- a/sc2/src/uqm/planets/generate/genmyc.c +++ b/sc2/src/uqm/planets/generate/genmyc.c @@ -18,6 +18,7 @@ #include "genall.h" #include "../planets.h" +#include "../scan.h" #include "../../build.h" #include "../../comm.h" #include "../../encount.h" @@ -161,8 +162,8 @@ GenerateMycon_generateOrbital (SOLARSYS_STATE *solarSys, PLANET_DESC *world) if (GET_GAME_STATE (KNOW_ABOUT_SHATTERED) == 0) SET_GAME_STATE (KNOW_ABOUT_SHATTERED, 1); - if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0))) + if (!isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, + ENERGY_SCAN, 0)) { LoadStdLanderFont (&solarSys->SysInfo.PlanetInfo); solarSys->PlanetSideFrame[1] = @@ -202,8 +203,7 @@ GenerateMycon_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, solarSys->SysInfo.PlanetInfo.CurType = 0; if (CurStarDescPtr->Index == SUN_DEVICE_DEFINED) { - if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (!isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0) && *whichNode == (COUNT)~0) { *whichNode = 1; @@ -211,8 +211,7 @@ GenerateMycon_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, else { *whichNode = 0; - if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { SET_GAME_STATE (SUN_DEVICE, 1); SET_GAME_STATE (SUN_DEVICE_ON_SHIP, 1); @@ -222,8 +221,7 @@ GenerateMycon_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, } else { - if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (!isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0) && *whichNode == (COUNT)~0) { *whichNode = 1; @@ -233,8 +231,7 @@ GenerateMycon_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, *whichNode = 0; // XXX: Why does this also test the PlanetInfo.DiscoveryString? // No other similar code ever tests the DiscoveryString. - if ((solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0) && solarSys->SysInfo.PlanetInfo.DiscoveryString) { switch (CurStarDescPtr->Index) diff --git a/sc2/src/uqm/planets/generate/genorz.c b/sc2/src/uqm/planets/generate/genorz.c index 4bca7dea2..982a57fe0 100644 --- a/sc2/src/uqm/planets/generate/genorz.c +++ b/sc2/src/uqm/planets/generate/genorz.c @@ -18,6 +18,7 @@ #include "genall.h" #include "../planets.h" +#include "../scan.h" #include "../../build.h" #include "../../comm.h" #include "../../encount.h" @@ -181,8 +182,7 @@ GenerateOrz_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; solarSys->SysInfo.PlanetInfo.CurDensity = 0; solarSys->SysInfo.PlanetInfo.CurType = 0; - if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (!isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0) && *whichNode == (COUNT)~0) { *whichNode = 1; @@ -190,8 +190,7 @@ GenerateOrz_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, else { *whichNode = 0; - if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { SET_GAME_STATE (TAALO_PROTECTOR, 1); SET_GAME_STATE (TAALO_PROTECTOR_ON_SHIP, 1); diff --git a/sc2/src/uqm/planets/generate/genpku.c b/sc2/src/uqm/planets/generate/genpku.c index 6cf2da875..4674c256d 100644 --- a/sc2/src/uqm/planets/generate/genpku.c +++ b/sc2/src/uqm/planets/generate/genpku.c @@ -19,6 +19,7 @@ #include "genall.h" #include "../lander.h" #include "../planets.h" +#include "../scan.h" #include "../../build.h" #include "../../comm.h" #include "../../globdata.h" @@ -139,11 +140,11 @@ GeneratePkunk_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, else solarSys->SysInfo.PlanetInfo.CurType = 1; solarSys->SysInfo.PlanetInfo.CurDensity = 0; - if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << i)) + + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i)) { - solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - &= ~(1L << i); + // Retrieval status is cleared to keep the node on the map + setNodeNotRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i); if (!GET_GAME_STATE (CLEAR_SPINDLE)) { @@ -153,6 +154,7 @@ GeneratePkunk_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, SET_GAME_STATE (CLEAR_SPINDLE_ON_SHIP, 1); } } + if (i >= *whichNode) break; } diff --git a/sc2/src/uqm/planets/generate/gensol.c b/sc2/src/uqm/planets/generate/gensol.c index 892f02bec..196b217d7 100644 --- a/sc2/src/uqm/planets/generate/gensol.c +++ b/sc2/src/uqm/planets/generate/gensol.c @@ -20,6 +20,7 @@ #include "../lander.h" #include "../lifeform.h" #include "../planets.h" +#include "../scan.h" #include "../../build.h" #include "../../encount.h" #include "../../globdata.h" @@ -521,13 +522,17 @@ GenerateSol_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, solarSys->SysInfo.PlanetInfo.CurPt.y = MAP_HEIGHT - 8; solarSys->SysInfo.PlanetInfo.CurDensity = 0; solarSys->SysInfo.PlanetInfo.CurType = 2; - if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { SET_GAME_STATE (FOUND_PLUTO_SPATHI, 1); - solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - &= ~(1L << 0); + // Retrieval status is cleared to keep the node on the map + // while the lander is taking off. FOUND_PLUTO_SPATHI bit + // will keep the node from showing up on subsequent visits. + setNodeNotRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0); SetLanderTakeoff (); + // XXX: This does NOT set *whichNode when the node is + // retrieved. Other similar pieces of code return the node + // count. See just below. AFAICT, the returned value is ignored. } else if (*whichNode == (COUNT)~0) *whichNode = 1; @@ -542,8 +547,7 @@ GenerateSol_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, solarSys->SysInfo.PlanetInfo.CurPt.y = MAP_HEIGHT * 1 / 4; solarSys->SysInfo.PlanetInfo.CurDensity = 0; solarSys->SysInfo.PlanetInfo.CurType = 0; - if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (!isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0) && *whichNode == (COUNT)~0) { *whichNode = 1; @@ -551,8 +555,7 @@ GenerateSol_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, else { *whichNode = 0; - if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { SET_GAME_STATE (MOONBASE_DESTROYED, 1); SET_GAME_STATE (MOONBASE_ON_SHIP, 1); diff --git a/sc2/src/uqm/planets/generate/genspa.c b/sc2/src/uqm/planets/generate/genspa.c index b6b11d09b..2dbfa7a41 100644 --- a/sc2/src/uqm/planets/generate/genspa.c +++ b/sc2/src/uqm/planets/generate/genspa.c @@ -19,6 +19,7 @@ #include "genall.h" #include "../lifeform.h" #include "../planets.h" +#include "../scan.h" #include "../../build.h" #include "../../comm.h" #include "../../globdata.h" @@ -209,8 +210,7 @@ GenerateSpathi_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; solarSys->SysInfo.PlanetInfo.CurDensity = 0; solarSys->SysInfo.PlanetInfo.CurType = 0; - if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (!isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0) && *whichNode == (COUNT)~0) { *whichNode = 1; @@ -218,8 +218,7 @@ GenerateSpathi_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, else { *whichNode = 0; - if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { SET_GAME_STATE (UMGAH_BROADCASTERS, 1); SET_GAME_STATE (UMGAH_BROADCASTERS_ON_SHIP, 1); diff --git a/sc2/src/uqm/planets/generate/gensup.c b/sc2/src/uqm/planets/generate/gensup.c index 31a77804f..798637dd8 100644 --- a/sc2/src/uqm/planets/generate/gensup.c +++ b/sc2/src/uqm/planets/generate/gensup.c @@ -19,6 +19,7 @@ #include "genall.h" #include "../lander.h" #include "../planets.h" +#include "../scan.h" #include "../../build.h" #include "../../comm.h" #include "../../globdata.h" @@ -142,11 +143,11 @@ GenerateSupox_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, else solarSys->SysInfo.PlanetInfo.CurType = 1; solarSys->SysInfo.PlanetInfo.CurDensity = 0; - if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << i)) + + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i)) { - solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - &= ~(1L << i); + // Retrieval status is cleared to keep the node on the map + setNodeNotRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, i); if (!GET_GAME_STATE (ULTRON_CONDITION)) { @@ -155,6 +156,7 @@ GenerateSupox_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, SET_GAME_STATE (ULTRON_CONDITION, 1); } } + if (i >= *whichNode) break; } diff --git a/sc2/src/uqm/planets/generate/genthrad.c b/sc2/src/uqm/planets/generate/genthrad.c index 402202dfe..0ef58dcd6 100644 --- a/sc2/src/uqm/planets/generate/genthrad.c +++ b/sc2/src/uqm/planets/generate/genthrad.c @@ -18,6 +18,7 @@ #include "genall.h" #include "../planets.h" +#include "../scan.h" #include "../../build.h" #include "../../comm.h" #include "../../encount.h" @@ -199,16 +200,15 @@ GenerateThraddash_generateEnergy (SOLARSYS_STATE *solarSys, (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; solarSys->SysInfo.PlanetInfo.CurDensity = 0; solarSys->SysInfo.PlanetInfo.CurType = 0; - if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) && *whichNode == (COUNT)~0) + if (!isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0) + && *whichNode == (COUNT)~0) { *whichNode = 1; } else { *whichNode = 0; - if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { SET_GAME_STATE (HELIX_VISITS, 0); SET_GAME_STATE (AQUA_HELIX, 1); diff --git a/sc2/src/uqm/planets/generate/genutw.c b/sc2/src/uqm/planets/generate/genutw.c index f5e8db2ab..14f55252f 100644 --- a/sc2/src/uqm/planets/generate/genutw.c +++ b/sc2/src/uqm/planets/generate/genutw.c @@ -18,6 +18,7 @@ #include "genall.h" #include "../planets.h" +#include "../scan.h" #include "../../build.h" #include "../../comm.h" #include "../../encount.h" @@ -251,8 +252,7 @@ GenerateUtwig_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, (HIBYTE (LOWORD (rand_val)) % (MAP_HEIGHT - (8 << 1))) + 8; solarSys->SysInfo.PlanetInfo.CurDensity = 0; solarSys->SysInfo.PlanetInfo.CurType = 0; - if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (!isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0) && *whichNode == (COUNT)~0) { *whichNode = 1; @@ -260,8 +260,7 @@ GenerateUtwig_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, else { *whichNode = 0; - if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { SET_GAME_STATE (UTWIG_BOMB, 1); SET_GAME_STATE (UTWIG_BOMB_ON_SHIP, 1); diff --git a/sc2/src/uqm/planets/generate/genvault.c b/sc2/src/uqm/planets/generate/genvault.c index c95afc185..cd2e3cf3f 100644 --- a/sc2/src/uqm/planets/generate/genvault.c +++ b/sc2/src/uqm/planets/generate/genvault.c @@ -19,6 +19,7 @@ #include "genall.h" #include "../lander.h" #include "../planets.h" +#include "../scan.h" #include "../../globdata.h" #include "../../nameref.h" #include "../../resinst.h" @@ -95,13 +96,17 @@ GenerateVault_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, solarSys->SysInfo.PlanetInfo.CurType = 0; else solarSys->SysInfo.PlanetInfo.CurType = 1; + // XXX: This node is always present, even after it is "picked up". + // Other similar pieces return the current node index when called + // by GeneratePlanetSide() to get the node info, and in that + // case the returned value is ignored AFAICT. *whichNode = 1; - if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { - solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - &= ~(1L << 0); + // Retrieval status is cleared to keep the node on the map + setNodeNotRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0); + if (GET_GAME_STATE (SYREEN_SHUTTLE_ON_SHIP)) { SetLanderTakeoff (); diff --git a/sc2/src/uqm/planets/generate/genvux.c b/sc2/src/uqm/planets/generate/genvux.c index ccc041a47..3f2833821 100644 --- a/sc2/src/uqm/planets/generate/genvux.c +++ b/sc2/src/uqm/planets/generate/genvux.c @@ -20,6 +20,7 @@ #include "../lander.h" #include "../lifeform.h" #include "../planets.h" +#include "../scan.h" #include "../../build.h" #include "../../comm.h" #include "../../encount.h" @@ -216,8 +217,7 @@ GenerateVux_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, solarSys->SysInfo.PlanetInfo.CurPt.y = MAP_HEIGHT * 5 / 8; solarSys->SysInfo.PlanetInfo.CurDensity = 0; solarSys->SysInfo.PlanetInfo.CurType = 0; - if (!(solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (!isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0) && *whichNode == (COUNT)~0) { *whichNode = 1; @@ -225,8 +225,7 @@ GenerateVux_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, else { *whichNode = 0; - if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { SET_GAME_STATE (SHOFIXTI_MAIDENS, 1); SET_GAME_STATE (MAIDENS_ON_SHIP, 1); @@ -326,9 +325,12 @@ GenerateVux_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world, else /* if (i <= 10) */ /* {BEHAVIOR_UNPREDICTABLE | SPEED_SLOW | DANGER_NORMAL, MAKE_BYTE (3, 8)}, */ solarSys->SysInfo.PlanetInfo.CurType = 8; + + // XXX: This currently does not need to be done in a loop. When a + // node is retrieved, the func is called with *whichNode==~0 if (i == 0 - && (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[BIOLOGICAL_SCAN] - & (1L << i)) + && isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, + BIOLOGICAL_SCAN, 0) && !GET_GAME_STATE (VUX_BEAST)) { UnbatchGraphics (); @@ -339,6 +341,7 @@ GenerateVux_generateLife (SOLARSYS_STATE *solarSys, PLANET_DESC *world, SET_GAME_STATE (VUX_BEAST, 1); SET_GAME_STATE (VUX_BEAST_ON_SHIP, 1); } + if (i >= *whichNode) break; } diff --git a/sc2/src/uqm/planets/generate/genwreck.c b/sc2/src/uqm/planets/generate/genwreck.c index 660fdeae9..26b02f65c 100644 --- a/sc2/src/uqm/planets/generate/genwreck.c +++ b/sc2/src/uqm/planets/generate/genwreck.c @@ -19,6 +19,7 @@ #include "genall.h" #include "../lander.h" #include "../planets.h" +#include "../scan.h" #include "../../globdata.h" #include "../../nameref.h" #include "../../resinst.h" @@ -89,12 +90,16 @@ GenerateWreck_generateEnergy (SOLARSYS_STATE *solarSys, PLANET_DESC *world, solarSys->SysInfo.PlanetInfo.CurType = 0; else solarSys->SysInfo.PlanetInfo.CurType = 1; + // XXX: This node is always present, even after it is "picked up". + // Other similar pieces return the current node index when called + // by GeneratePlanetSide() to get the node info, and in that + // case the returned value is ignored AFAICT. *whichNode = 1; - if (solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - & (1L << 0)) + + if (isNodeRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0)) { - solarSys->SysInfo.PlanetInfo.ScanRetrieveMask[ENERGY_SCAN] - &= ~(1L << 0); + // Retrieval status is cleared to keep the node on the map + setNodeNotRetrieved (&solarSys->SysInfo.PlanetInfo, ENERGY_SCAN, 0); if (!GET_GAME_STATE (PORTAL_KEY)) { diff --git a/sc2/src/uqm/planets/lander.c b/sc2/src/uqm/planets/lander.c index 29cf317dd..2a48dbf7d 100644 --- a/sc2/src/uqm/planets/lander.c +++ b/sc2/src/uqm/planets/lander.c @@ -858,15 +858,15 @@ CheckObjectCollision (COUNT index) } which_node = HIBYTE (ElementPtr->scan_node) - 1; - pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[scan] |= - (1L << which_node); + setNodeRetrieved (&pSolarSysState->SysInfo.PlanetInfo, scan, + which_node); allNodes = (COUNT)~0; callGenerateForScanType (pSolarSysState, pSolarSysState->pOrbitalDesc, &allNodes, scan); - if (!(pSolarSysState->SysInfo.PlanetInfo.ScanRetrieveMask[scan] & - (1L << which_node))) + if (!isNodeRetrieved (&pSolarSysState->SysInfo.PlanetInfo, scan, + which_node)) { /* If our discovery strings have cycled, we're done */ if (GetStringTableIndex (