diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 25f071053..3de63073e 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ Changes towards version 0.7: +- Prevent overflow for planet weight when scanning a planet + - from Benjamin Alan Weaver - Don't set _POSIX_THREAD_SAFE_FUNCTIONS - SvdB - Support for Windows CE. - SvdB with Pavel Chernikov - Added support to the unix build system for explicitely specifying the name diff --git a/sc2/src/sc2code/planets/scan.c b/sc2/src/sc2code/planets/scan.c index 4462e6096..330696911 100644 --- a/sc2/src/sc2code/planets/scan.c +++ b/sc2/src/sc2code/planets/scan.c @@ -301,7 +301,7 @@ PrintCoarseScanPC (void) PrintScanTitlePC (&t, &r, GAME_STRING (ORBITSCAN_STRING_BASE + 11), RIGHT_SIDE_BASELINE_X_PC); // "Mass: " val = pSolarSysState->SysInfo.PlanetInfo.PlanetRadius; - val = (val * val * val / 100L + val = ((DWORD) val * (DWORD) val * (DWORD) val / 100L * pSolarSysState->SysInfo.PlanetInfo.PlanetDensity + ((100L * 100L) >> 1)) / (100L * 100L); if (val == 0) @@ -522,7 +522,7 @@ PrintCoarseScan3DO (void) LockMutex (GraphicsLock); t.pStr = buf; val = pSolarSysState->SysInfo.PlanetInfo.PlanetRadius; - val = (val * val * val / 100L + val = ((DWORD) val * (DWORD) val * (DWORD) val / 100L * pSolarSysState->SysInfo.PlanetInfo.PlanetDensity + ((100L * 100L) >> 1)) / (100L * 100L); if (val == 0)