Fixed the starmap fuel range circle overflow; bug #1130; also cap the range circle at a sensible level to prevent further overflows

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3646 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2011-07-15 16:09:12 +00:00
parent c0bc500620
commit fe51b00589
2 changed files with 10 additions and 4 deletions
+1
View File
@@ -1,4 +1,5 @@
Changes towards version 0.8: Changes towards version 0.8:
- Fixed starmap fuel range circle shrinking (bug #1130) - Alex
- Added gamma correction to the setup menu (bug #977) - Alex, Nic - Added gamma correction to the setup menu (bug #977) - Alex, Nic
- Refactor Melnorme comm code to make modding easier; step 1 (bug #1128), - Refactor Melnorme comm code to make modding easier; step 1 (bug #1128),
from Scott A. Colcord from Scott A. Colcord
+9 -4
View File
@@ -68,18 +68,18 @@ signedDivWithError (long val, long divisor)
#define MAP_FIT_X ((MAX_X_UNIVERSE + 1) / SIS_SCREEN_WIDTH + 1) #define MAP_FIT_X ((MAX_X_UNIVERSE + 1) / SIS_SCREEN_WIDTH + 1)
static inline COORD static inline COORD
universeToDispx (COORD ux) universeToDispx (long ux)
{ {
return signedDivWithError ((((long)ux - mapOrigin.x) << zoomLevel) return signedDivWithError (((ux - mapOrigin.x) << zoomLevel)
* SIS_SCREEN_WIDTH, MAX_X_UNIVERSE + MAP_FIT_X) * SIS_SCREEN_WIDTH, MAX_X_UNIVERSE + MAP_FIT_X)
+ ((SIS_SCREEN_WIDTH - 1) >> 1); + ((SIS_SCREEN_WIDTH - 1) >> 1);
} }
#define UNIVERSE_TO_DISPX(ux) universeToDispx(ux) #define UNIVERSE_TO_DISPX(ux) universeToDispx(ux)
static inline COORD static inline COORD
universeToDispy (COORD uy) universeToDispy (long uy)
{ {
return signedDivWithError ((((long)mapOrigin.y - uy) << zoomLevel) return signedDivWithError (((mapOrigin.y - uy) << zoomLevel)
* SIS_SCREEN_HEIGHT, MAX_Y_UNIVERSE + 2) * SIS_SCREEN_HEIGHT, MAX_Y_UNIVERSE + 2)
+ ((SIS_SCREEN_HEIGHT - 1) >> 1); + ((SIS_SCREEN_HEIGHT - 1) >> 1);
} }
@@ -343,6 +343,7 @@ DrawStarMap (COUNT race_update, RECT *pClipRect)
} }
ClearDrawable (); ClearDrawable ();
// Draw the fuel range circle
if (race_update == 0 if (race_update == 0
&& which_space < 2 && which_space < 2
&& (diameter = (long)GLOBAL_SIS (FuelOnBoard) << 1)) && (diameter = (long)GLOBAL_SIS (FuelOnBoard) << 1))
@@ -357,6 +358,10 @@ DrawStarMap (COUNT race_update, RECT *pClipRect)
r.corner.y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y)); r.corner.y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y));
} }
// Cap the diameter to a sane range
if (diameter > MAX_X_UNIVERSE * 4)
diameter = MAX_X_UNIVERSE * 4;
r.extent.width = UNIVERSE_TO_DISPX (diameter) r.extent.width = UNIVERSE_TO_DISPX (diameter)
- UNIVERSE_TO_DISPX (0); - UNIVERSE_TO_DISPX (0);
if (r.extent.width < 0) if (r.extent.width < 0)