From 3c22948d78e5197e788ba0dbd83f2154f54b859f Mon Sep 17 00:00:00 2001 From: avolkov Date: Tue, 8 Sep 2009 22:56:02 +0000 Subject: [PATCH] Bug #945 explained; solution included git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3180 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/units.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sc2/src/sc2code/units.h b/sc2/src/sc2code/units.h index e7f256f5c..67d7bcf13 100644 --- a/sc2/src/sc2code/units.h +++ b/sc2/src/sc2code/units.h @@ -82,8 +82,6 @@ extern int ScreenHeight; ((UNIVERSE_TO_LOGY (MAX_Y_UNIVERSE + 1) > UNIVERSE_TO_LOGY (-1) ? \ UNIVERSE_TO_LOGY (MAX_Y_UNIVERSE + 1) : UNIVERSE_TO_LOGY (-1)) \ - 1L) -#define SECTOR_WIDTH 195 -#define SECTOR_HEIGHT 25 #define SPHERE_RADIUS_INCREMENT 11 @@ -92,10 +90,28 @@ extern int ScreenHeight; #define UNIT_SCREEN_WIDTH 63 #define UNIT_SCREEN_HEIGHT 50 +// Bug #945: Simplified, these set the speed of SIS in Hyperspace and +// Quasispace. The ratio between UNIVERSE_UNITS_ and LOG_UNITS_ is +// what sets the speed, and it should be 1:16 to match the original. +// The unit factors are reduced to keep the translation math within +// 32 bits. The original math is unnecessarily complex and depends +// on the screen resolution when it should not. +// Using the new math will break old savegames. +#ifdef NORMALIZED_HYPERSPACE_SPEED +#define LOG_UNITS_X ((SDWORD)(UNIVERSE_UNITS_X * 16)) +#define LOG_UNITS_Y ((SDWORD)(UNIVERSE_UNITS_Y * 16)) +#define UNIVERSE_UNITS_X (((MAX_X_UNIVERSE + 1) >> 4)) +#define UNIVERSE_UNITS_Y (((MAX_Y_UNIVERSE + 1) >> 4)) +#else +// Original (and now broken) Hyperspace speed factors +#define SECTOR_WIDTH 195 +#define SECTOR_HEIGHT 25 + #define LOG_UNITS_X ((SDWORD)(LOG_SPACE_WIDTH >> 4) * SECTOR_WIDTH) #define LOG_UNITS_Y ((SDWORD)(LOG_SPACE_HEIGHT >> 4) * SECTOR_HEIGHT) #define UNIVERSE_UNITS_X (((MAX_X_UNIVERSE + 1) >> 4) * 10) #define UNIVERSE_UNITS_Y (((MAX_Y_UNIVERSE + 1) >> 4)) +#endif #define ROUNDING_ERROR(div) ((div) >> 1)