From 9febcd9f1869aa7bf9819669978858f2fe737451 Mon Sep 17 00:00:00 2001 From: avolkov Date: Sun, 8 May 2011 19:52:58 +0000 Subject: [PATCH] Fix the reachable Hyperspace coordinates regression introduced by rounding error correction in r3162; also remove the ?: operator from the affected constants to keep it clean, since we will never invert the axes git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3601 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/uqm/units.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sc2/src/uqm/units.h b/sc2/src/uqm/units.h index 5a0ae5ffc..303e50558 100644 --- a/sc2/src/uqm/units.h +++ b/sc2/src/uqm/units.h @@ -92,14 +92,17 @@ extern int ScreenHeight; #define MAX_X_UNIVERSE 9999 #define MAX_Y_UNIVERSE 9999 +// Due to the added rounding error correction, the maximum logical X and Y +// in Hyperspace cannot go past 999.94999, otherwise the values will be +// rounded up to 1000.0. We do not want that so we subtract half a unit. #define MAX_X_LOGICAL \ - ((UNIVERSE_TO_LOGX (MAX_X_UNIVERSE + 1) > UNIVERSE_TO_LOGX (-1) ? \ - UNIVERSE_TO_LOGX (MAX_X_UNIVERSE + 1) : UNIVERSE_TO_LOGX (-1)) \ - - 1L) + (UNIVERSE_TO_LOGX (MAX_X_UNIVERSE + 1) - (UNIVERSE_TO_LOGX (1) >> 1) \ + - 1L) +// The Y axis is inverted with respect to the screen Y axis. +// (MAX_Y_UNIVERSE - 1) is really 1 for our purposes. #define MAX_Y_LOGICAL \ - ((UNIVERSE_TO_LOGY (MAX_Y_UNIVERSE + 1) > UNIVERSE_TO_LOGY (-1) ? \ - UNIVERSE_TO_LOGY (MAX_Y_UNIVERSE + 1) : UNIVERSE_TO_LOGY (-1)) \ - - 1L) + (UNIVERSE_TO_LOGY (-1) - (UNIVERSE_TO_LOGY (MAX_Y_UNIVERSE - 1) >> 1) \ + - 1L) #define SPHERE_RADIUS_INCREMENT 11