diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 0f140c2d6..89b885ed2 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Better location description in savegame summaries (bug #844) - Alex - Fixed crash when saving a game into the last slot while having too many devices on board - Alex - Allow any sound data format to be graphed by comm oscilloscope; also diff --git a/sc2/content/base/gamestrings.txt b/sc2/content/base/gamestrings.txt index 887a28ef3..3ed6e6766 100644 --- a/sc2/content/base/gamestrings.txt +++ b/sc2/content/base/gamestrings.txt @@ -1625,6 +1625,8 @@ Planet XV #(Planet XVI) Planet XVI +#(Sa-Matra) +Sa-Matra #(JAN) JAN diff --git a/sc2/src/sc2code/gameopt.c b/sc2/src/sc2code/gameopt.c index 44ac6cdfe..b286707e0 100644 --- a/sc2/src/sc2code/gameopt.c +++ b/sc2/src/sc2code/gameopt.c @@ -804,17 +804,26 @@ ShowSummary (SUMMARY_DESC *pSD) t.CharCount = (COUNT)~0; font_DrawText (&t); t.align = ALIGN_CENTER; - t.baseline.x = SIS_SCREEN_WIDTH - SIS_TITLE_BOX_WIDTH - 3 + t.baseline.x = SIS_SCREEN_WIDTH - SIS_TITLE_BOX_WIDTH - 4 + (SIS_TITLE_WIDTH >> 1); - if (pSD->Activity == IN_STARBASE) - utf8StringCopy (buf, sizeof (buf), - GAME_STRING (STARBASE_STRING_BASE)); - else if (pSD->Activity == IN_PLANET_ORBIT) - utf8StringCopy (buf, sizeof (buf), GLOBAL_SIS (PlanetName)); - else - sprintf (buf, "%03u.%01u : %03u.%01u", - r.corner.x / 10, r.corner.x % 10, - r.corner.y / 10, r.corner.y % 10); + switch (pSD->Activity) + { + case IN_STARBASE: + utf8StringCopy (buf, sizeof (buf), // Starbase + GAME_STRING (STARBASE_STRING_BASE)); + break; + case IN_LAST_BATTLE: + utf8StringCopy (buf, sizeof (buf), // Sa-Matra + GAME_STRING (PLANET_NUMBER_BASE + 32)); + break; + case IN_PLANET_ORBIT: + utf8StringCopy (buf, sizeof (buf), GLOBAL_SIS (PlanetName)); + break; + default: + sprintf (buf, "%03u.%01u : %03u.%01u", + r.corner.x / 10, r.corner.x % 10, + r.corner.y / 10, r.corner.y % 10); + } t.CharCount = (COUNT)~0; font_DrawText (&t); diff --git a/sc2/src/sc2code/gamestr.h b/sc2/src/sc2code/gamestr.h index 0fa242b65..48a811ba0 100644 --- a/sc2/src/sc2code/gamestr.h +++ b/sc2/src/sc2code/gamestr.h @@ -31,7 +31,7 @@ #define ELEMENTS_STRING_COUNT 133 #define SCAN_STRING_COUNT 56 #define STAR_NUMBER_COUNT 14 -#define PLANET_NUMBER_COUNT 32 +#define PLANET_NUMBER_COUNT 33 #define MONTHS_STRING_COUNT 12 #define FEEDBACK_STRING_COUNT 2 #define STARBASE_STRING_COUNT 5 diff --git a/sc2/src/sc2code/planets/planets.h b/sc2/src/sc2code/planets/planets.h index 133b2ae7d..f6a1a94eb 100644 --- a/sc2/src/sc2code/planets/planets.h +++ b/sc2/src/sc2code/planets/planets.h @@ -255,5 +255,8 @@ extern void GeneratePlanetMask (PLANET_DESC *pPlanetDesc, FRAME SurfDefFrame); extern void DeltaTopography (COUNT num_iterations, SBYTE *DepthArray, RECT *pRect, SIZE depth_delta); +extern UNICODE* GetNamedPlanetaryBody (void); +extern void GetPlanetOrMoonName (UNICODE *buf, COUNT bufsize); + #endif /* _PLANETS_H */ diff --git a/sc2/src/sc2code/planets/scan.c b/sc2/src/sc2code/planets/scan.c index c3dca93b4..5d5810c0a 100644 --- a/sc2/src/sc2code/planets/scan.c +++ b/sc2/src/sc2code/planets/scan.c @@ -124,6 +124,33 @@ MakeScanValue (UNICODE *buf, long val, const UNICODE *extra) } } +static void +GetPlanetTitle (UNICODE *buf, COUNT bufsize) +{ + int val; + UNICODE *named = GetNamedPlanetaryBody (); + if (named) + { + utf8StringCopy (buf, bufsize, named); + return; + } + + // Unnamed body, use world type + val = pSolarSysState->pOrbitalDesc->data_index & ~PLANET_SHIELDED; + if (val >= FIRST_GAS_GIANT) + { + sprintf (buf, "%s", GAME_STRING (SCAN_STRING_BASE + 4 + 51)); + // Gas Giant + } + else + { + sprintf (buf, "%s %s", + GAME_STRING (SCAN_STRING_BASE + 4 + val), + GAME_STRING (SCAN_STRING_BASE + 4 + 50)); + // World + } +} + static void PrintCoarseScanPC (void) { @@ -133,67 +160,11 @@ PrintCoarseScanPC (void) RECT r; UNICODE buf[200]; + GetPlanetTitle (buf, sizeof (buf)); + LockMutex (GraphicsLock); SetContext (SpaceContext); - if (CurStarDescPtr->Index == SOL_DEFINED) - { - if (pSolarSysState->pOrbitalDesc->pPrevDesc == - &pSolarSysState->SunDesc[0]) - utf8StringCopy (buf, sizeof (buf), GLOBAL_SIS (PlanetName)); - else - { - switch (pSolarSysState->pOrbitalDesc->pPrevDesc - - pSolarSysState->PlanetDesc) - { - case 2: /* EARTH */ - utf8StringCopy (buf, sizeof (buf), - GAME_STRING (PLANET_NUMBER_BASE + 9)); - break; - case 4: /* JUPITER */ - switch (pSolarSysState->pOrbitalDesc - - pSolarSysState->MoonDesc) - { - case 0: - utf8StringCopy (buf, sizeof (buf), - GAME_STRING (PLANET_NUMBER_BASE + 10)); - break; - case 1: - utf8StringCopy (buf, sizeof (buf), - GAME_STRING (PLANET_NUMBER_BASE + 11)); - break; - case 2: - utf8StringCopy (buf, sizeof (buf), - GAME_STRING (PLANET_NUMBER_BASE + 12)); - break; - case 3: - utf8StringCopy (buf, sizeof (buf), - GAME_STRING (PLANET_NUMBER_BASE + 13)); - break; - } - break; - case 5: /* SATURN */ - utf8StringCopy (buf, sizeof (buf), - GAME_STRING (PLANET_NUMBER_BASE + 14)); - break; - case 7: /* NEPTUNE */ - utf8StringCopy (buf, sizeof (buf), - GAME_STRING (PLANET_NUMBER_BASE + 15)); - break; - } - } - } - else - { - val = pSolarSysState->pOrbitalDesc->data_index & ~PLANET_SHIELDED; - if (val >= FIRST_GAS_GIANT) - sprintf (buf, "%s", GAME_STRING (SCAN_STRING_BASE + 4 + 51)); - else - sprintf (buf, "%s %s", - GAME_STRING (SCAN_STRING_BASE + 4 + val), - GAME_STRING (SCAN_STRING_BASE + 4 + 50)); - } - t.align = ALIGN_CENTER; t.baseline.x = SIS_SCREEN_WIDTH >> 1; t.baseline.y = 13; @@ -375,66 +346,11 @@ PrintCoarseScan3DO (void) STAMP s; UNICODE buf[200]; + GetPlanetTitle (buf, sizeof (buf)); + LockMutex (GraphicsLock); SetContext (SpaceContext); - if (CurStarDescPtr->Index == SOL_DEFINED) - { - if (pSolarSysState->pOrbitalDesc->pPrevDesc == &pSolarSysState->SunDesc[0]) - utf8StringCopy (buf, sizeof (buf), GLOBAL_SIS (PlanetName)); - else - { - switch (pSolarSysState->pOrbitalDesc->pPrevDesc - - pSolarSysState->PlanetDesc) - { - case 2: /* EARTH */ - utf8StringCopy (buf, sizeof (buf), - GAME_STRING (PLANET_NUMBER_BASE + 9)); - break; - case 4: /* JUPITER */ - switch (pSolarSysState->pOrbitalDesc - - pSolarSysState->MoonDesc) - { - case 0: - utf8StringCopy (buf, sizeof (buf), - GAME_STRING (PLANET_NUMBER_BASE + 10)); - break; - case 1: - utf8StringCopy (buf, sizeof (buf), - GAME_STRING (PLANET_NUMBER_BASE + 11)); - break; - case 2: - utf8StringCopy (buf, sizeof (buf), - GAME_STRING (PLANET_NUMBER_BASE + 12)); - break; - case 3: - utf8StringCopy (buf, sizeof (buf), - GAME_STRING (PLANET_NUMBER_BASE + 13)); - break; - } - break; - case 5: /* SATURN */ - utf8StringCopy (buf, sizeof (buf), - GAME_STRING (PLANET_NUMBER_BASE + 14)); - break; - case 7: /* NEPTUNE */ - utf8StringCopy (buf, sizeof (buf), - GAME_STRING (PLANET_NUMBER_BASE + 15)); - break; - } - } - } - else - { - val = pSolarSysState->pOrbitalDesc->data_index & ~PLANET_SHIELDED; - if (val >= FIRST_GAS_GIANT) - sprintf (buf, "%s", GAME_STRING (SCAN_STRING_BASE + 4 + 51)); - else - sprintf (buf, "%s %s", - GAME_STRING (SCAN_STRING_BASE + 4 + val), - GAME_STRING (SCAN_STRING_BASE + 4 + 50)); - } - t.align = ALIGN_CENTER; t.baseline.x = SIS_SCREEN_WIDTH >> 1; t.baseline.y = 13; diff --git a/sc2/src/sc2code/planets/solarsys.c b/sc2/src/sc2code/planets/solarsys.c index c0743496c..b0bdf8fa9 100644 --- a/sc2/src/sc2code/planets/solarsys.c +++ b/sc2/src/sc2code/planets/solarsys.c @@ -1937,4 +1937,112 @@ ExploreSolarSys (void) pSolarSysState = 0; } +UNICODE * +GetNamedPlanetaryBody (void) +{ + int planet; + int moon; + int parent_planet; + if (!CurStarDescPtr || !pSolarSysState || !pSolarSysState->pOrbitalDesc) + return NULL; // Not inside an inner system, so no name + + planet = pSolarSysState->pOrbitalDesc - pSolarSysState->PlanetDesc; + moon = pSolarSysState->pOrbitalDesc - pSolarSysState->MoonDesc; + parent_planet = pSolarSysState->pOrbitalDesc->pPrevDesc + - pSolarSysState->PlanetDesc; + + if (CurStarDescPtr->Index == SOL_DEFINED) + { // Planets and moons in Sol + if (pSolarSysState->pOrbitalDesc->pPrevDesc == pSolarSysState->SunDesc) + { // A planet + return GAME_STRING (PLANET_NUMBER_BASE + planet); + } + // Moons + switch (parent_planet) + { + case 2: // Earth + switch (moon) + { + case 0: // Starbase + return GAME_STRING (STARBASE_STRING_BASE + 0); + case 1: // Luna + return GAME_STRING (PLANET_NUMBER_BASE + 9); + } + break; + case 4: // Jupiter + switch (moon) + { + case 0: // Io + return GAME_STRING (PLANET_NUMBER_BASE + 10); + case 1: // Europa + return GAME_STRING (PLANET_NUMBER_BASE + 11); + case 2: // Ganymede + return GAME_STRING (PLANET_NUMBER_BASE + 12); + case 3: // Callisto + return GAME_STRING (PLANET_NUMBER_BASE + 13); + } + break; + case 5: // Saturn + if (moon == 0) // Titan + return GAME_STRING (PLANET_NUMBER_BASE + 14); + break; + case 7: // Neptune + if (moon == 0) // Triton + return GAME_STRING (PLANET_NUMBER_BASE + 15); + break; + } + } + else if (CurStarDescPtr->Index == SPATHI_DEFINED) + { + if (pSolarSysState->pOrbitalDesc->pPrevDesc == pSolarSysState->SunDesc) + { // A planet +#ifdef NOTYET + if (planet == 0) + return "Spathiwa"; +#endif // NOTYET + } + } + else if (CurStarDescPtr->Index == SAMATRA_DEFINED) + { + if (parent_planet == 4 && moon == 0) // Sa-Matra + return GAME_STRING (PLANET_NUMBER_BASE + 32); + } + + return NULL; +} + +void +GetPlanetOrMoonName (UNICODE *buf, COUNT bufsize) +{ + UNICODE *named; + int moon; + int i; + + named = GetNamedPlanetaryBody (); + if (named) + { + utf8StringCopy (buf, bufsize, named); + return; + } + + // Either not named or we already have a name + utf8StringCopy (buf, bufsize, GLOBAL_SIS (PlanetName)); + + if (!pSolarSysState || !pSolarSysState->pOrbitalDesc || + pSolarSysState->pOrbitalDesc->pPrevDesc == pSolarSysState->SunDesc) + { // Outer or inner system or orbiting a planet + return; + } + + // Orbiting an unnamed moon + i = strlen (buf); + buf += i; + bufsize -= i; + moon = pSolarSysState->pOrbitalDesc - pSolarSysState->MoonDesc; + if (bufsize >= 3) + { + snprintf (buf, bufsize, "-%c", 'A' + moon); + buf[bufsize - 1] = '\0'; + } +} diff --git a/sc2/src/sc2code/save.c b/sc2/src/sc2code/save.c index f7d91df62..25bea847a 100644 --- a/sc2/src/sc2code/save.c +++ b/sc2/src/sc2code/save.c @@ -467,18 +467,27 @@ PrepareSummary (SUMMARY_DESC *SummPtr) { SummPtr->SS = GlobData.SIS_state; - switch (SummPtr->Activity = LOBYTE (GLOBAL (CurrentActivity))) + SummPtr->Activity = LOBYTE (GLOBAL (CurrentActivity)); + switch (SummPtr->Activity) { case IN_HYPERSPACE: if (GET_GAME_STATE (ARILOU_SPACE_SIDE) > 1) SummPtr->Activity = IN_QUASISPACE; break; case IN_INTERPLANETARY: + // Get a better planet name for summary + GetPlanetOrMoonName (SummPtr->SS.PlanetName, + sizeof (SummPtr->SS.PlanetName)); if (GET_GAME_STATE (GLOBAL_FLAGS_AND_DATA) == (BYTE)~0) SummPtr->Activity = IN_STARBASE; else if (pSolarSysState && pSolarSysState->MenuState.Initialized >= 3) SummPtr->Activity = IN_PLANET_ORBIT; break; + case IN_LAST_BATTLE: + utf8StringCopy (SummPtr->SS.PlanetName, + sizeof (SummPtr->SS.PlanetName), + GAME_STRING (PLANET_NUMBER_BASE + 32)); // Sa-Matra + break; } SummPtr->MCreditLo = GET_GAME_STATE (MELNORME_CREDIT0);