From 98488b97e4d4bc204185309c5e1b6d903db86435 Mon Sep 17 00:00:00 2001 From: Meep-Eep Date: Sat, 5 Jan 2008 19:27:48 +0000 Subject: [PATCH] Prevent overflow for planet weight when scanning a planet. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2893 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 2 ++ sc2/src/sc2code/planets/scan.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) 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)