diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 1e6ad0f82..c2a6c6c5d 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ Changes towards version 0.7: +- Change hardcoded Starbase and Sa-Matra values to pretty enum values + (bug #1047), from Nic - Load override.cfg from user's dir to add or override menu controls - Alex - Allow addons to override any content by placing zips into their 'shadow-content' dir - Alex diff --git a/sc2/src/sc2code/planets/calc.c b/sc2/src/sc2code/planets/calc.c index 30cac7782..206b91dd8 100644 --- a/sc2/src/sc2code/planets/calc.c +++ b/sc2/src/sc2code/planets/calc.c @@ -235,8 +235,7 @@ DoPlanetaryAnalysis (SYSTEM_INFO *SysInfoPtr, PLANET_DESC *pPlanetDesc) { DWORD old_seed; - /* Earth Starbase */ - if (pPlanetDesc->data_index == (BYTE)~0) + if (pPlanetDesc->data_index == HIERARCHY_STARBASE) return (0); old_seed = TFB_SeedRandom (pPlanetDesc->rand_seed); diff --git a/sc2/src/sc2code/planets/genchmmr.c b/sc2/src/sc2code/planets/genchmmr.c index f0b477c9d..9defe44aa 100644 --- a/sc2/src/sc2code/planets/genchmmr.c +++ b/sc2/src/sc2code/planets/genchmmr.c @@ -41,7 +41,7 @@ GenerateChmmr (BYTE control) COUNT angle; DWORD rand_val; - pSolarSysState->MoonDesc[0].data_index = (BYTE)~0; + pSolarSysState->MoonDesc[0].data_index = HIERARCHY_STARBASE; pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS; rand_val = TFB_Random (); angle = NORMALIZE_ANGLE (LOWORD (rand_val)); diff --git a/sc2/src/sc2code/planets/gensam.c b/sc2/src/sc2code/planets/gensam.c index 626b8eb7f..5728ef9e2 100644 --- a/sc2/src/sc2code/planets/gensam.c +++ b/sc2/src/sc2code/planets/gensam.c @@ -186,7 +186,7 @@ GenerateSamatra (BYTE control) COUNT angle; DWORD rand_val; - pSolarSysState->MoonDesc[0].data_index = (BYTE)(~0 - 1); + pSolarSysState->MoonDesc[0].data_index = SA_MATRA; pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS + (2 * MOON_DELTA); rand_val = TFB_Random (); diff --git a/sc2/src/sc2code/planets/gensol.c b/sc2/src/sc2code/planets/gensol.c index f7d62f55b..e458f8c50 100644 --- a/sc2/src/sc2code/planets/gensol.c +++ b/sc2/src/sc2code/planets/gensol.c @@ -462,7 +462,7 @@ GenerateSOL (BYTE control) COUNT angle; /* Starbase: */ - pSolarSysState->MoonDesc[0].data_index = (BYTE)~0; + pSolarSysState->MoonDesc[0].data_index = HIERARCHY_STARBASE; pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS; angle = HALF_CIRCLE + QUADRANT; pSolarSysState->MoonDesc[0].location.x = diff --git a/sc2/src/sc2code/planets/gensyr.c b/sc2/src/sc2code/planets/gensyr.c index be5992c70..68be4642b 100644 --- a/sc2/src/sc2code/planets/gensyr.c +++ b/sc2/src/sc2code/planets/gensyr.c @@ -75,7 +75,7 @@ GenerateSyreen (BYTE control) GenerateRandomIP (GENERATE_MOONS); if (pSolarSysState->pBaseDesc == &pSolarSysState->PlanetDesc[0]) { - pSolarSysState->MoonDesc[0].data_index = (BYTE)~0; + pSolarSysState->MoonDesc[0].data_index = HIERARCHY_STARBASE; pSolarSysState->MoonDesc[0].radius = MIN_MOON_RADIUS; pSolarSysState->MoonDesc[0].location.x = COSINE (QUADRANT, pSolarSysState->MoonDesc[0].radius); diff --git a/sc2/src/sc2code/planets/plandata.h b/sc2/src/sc2code/planets/plandata.h index cc0292886..10b8adfb3 100644 --- a/sc2/src/sc2code/planets/plandata.h +++ b/sc2/src/sc2code/planets/plandata.h @@ -180,7 +180,13 @@ enum YEL_GAS_GIANT, LAST_GAS_GIANT = YEL_GAS_GIANT, - NUMBER_OF_PLANET_TYPES + NUMBER_OF_PLANET_TYPES, + + WORLD_TYPE_SPECIAL = 0x80, + PLANET_SHIELDED = WORLD_TYPE_SPECIAL, + + HIERARCHY_STARBASE = 127 | WORLD_TYPE_SPECIAL, + SA_MATRA = 126 | WORLD_TYPE_SPECIAL, }; #define NUMBER_OF_SMALL_ROCKY_WORLDS (LAST_SMALL_ROCKY_WORLD - FIRST_SMALL_ROCKY_WORLD + 1) diff --git a/sc2/src/sc2code/planets/planets.h b/sc2/src/sc2code/planets/planets.h index 43a82abdf..133b2ae7d 100644 --- a/sc2/src/sc2code/planets/planets.h +++ b/sc2/src/sc2code/planets/planets.h @@ -113,8 +113,6 @@ enum #define MIN_MOON_RADIUS 35 #define MOON_DELTA 20 -#define PLANET_SHIELDED (1 << 7) - typedef struct planet_desc { DWORD rand_seed; diff --git a/sc2/src/sc2code/planets/solarsys.c b/sc2/src/sc2code/planets/solarsys.c index 13196fe6f..d429ab24b 100644 --- a/sc2/src/sc2code/planets/solarsys.c +++ b/sc2/src/sc2code/planets/solarsys.c @@ -152,15 +152,13 @@ GenerateMoons (void) pMoonDesc->temp_color = pCurDesc->temp_color; data_index = pMoonDesc->data_index; - if (data_index == (BYTE)~0) + if (data_index == HIERARCHY_STARBASE) { - /* Starbase */ pMoonDesc->image.frame = SetAbsFrameIndex (SpaceJunkFrame, 16); } - else if (data_index == (BYTE)(~0 - 1)) + else if (data_index == SA_MATRA) { - /* Sa-Matra */ pMoonDesc->image.frame = SetAbsFrameIndex (SpaceJunkFrame, 19); } diff --git a/sc2/src/sc2code/uqmdebug.c b/sc2/src/sc2code/uqmdebug.c index 384fab7ef..f5be6c551 100644 --- a/sc2/src/sc2code/uqmdebug.c +++ b/sc2/src/sc2code/uqmdebug.c @@ -991,11 +991,11 @@ dumpMoon (FILE *out, const PLANET_DESC *moon) { const char *typeStr; - if (moon->data_index == (BYTE) ~0) + if (moon->data_index == HIERARCHY_STARBASE) { typeStr = "StarBase"; } - else if (moon->data_index == (BYTE) (~0 - 1)) + else if (moon->data_index == SA_MATRA) { typeStr = "Sa-Matra"; } @@ -1014,13 +1014,11 @@ dumpWorld (FILE *out, const PLANET_DESC *world) { PLANET_INFO *info; - if (world->data_index == (BYTE) ~0) { - // StarBase + if (world->data_index == HIERARCHY_STARBASE) { return; } - if (world->data_index == (BYTE)(~0 - 1)) { - // Sa-Matra + if (world->data_index == SA_MATRA) { return; } @@ -1240,13 +1238,11 @@ tallyMoonCallback (const PLANET_DESC *moon, void *arg) static void tallyResourcesWorld (TallyResourcesArg *arg, const PLANET_DESC *world) { - if (world->data_index == (BYTE) ~0) { - // StarBase + if (world->data_index == HIERARCHY_STARBASE) { return; } - if (world->data_index == (BYTE)(~0 - 1)) { - // Sa-Matra + if (world->data_index == SA_MATRA) { return; }