Starmap unit conversion corrections and lazy-cursor fix; fixes bug #970
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3163 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
Changes towards version 0.7:
|
Changes towards version 0.7:
|
||||||
|
- Starmap unit conversion corrections; fixes bug #970 - Alex
|
||||||
- Rounding-error correction in log(x|y)ToUniverse (bug #1046), from Nic
|
- Rounding-error correction in log(x|y)ToUniverse (bug #1046), from Nic
|
||||||
- Change hardcoded Starbase and Sa-Matra values to pretty enum values
|
- Change hardcoded Starbase and Sa-Matra values to pretty enum values
|
||||||
(bug #1047), from Nic
|
(bug #1047), from Nic
|
||||||
|
|||||||
@@ -36,23 +36,58 @@
|
|||||||
#include "libs/mathlib.h"
|
#include "libs/mathlib.h"
|
||||||
|
|
||||||
|
|
||||||
|
static inline long
|
||||||
|
signedDivWithError (long val, long divisor)
|
||||||
|
{
|
||||||
|
int invert = 0;
|
||||||
|
if (val < 0)
|
||||||
|
{
|
||||||
|
invert = 1;
|
||||||
|
val = -val;
|
||||||
|
}
|
||||||
|
val = (val + ROUNDING_ERROR (divisor)) / divisor;
|
||||||
|
return invert ? -val : val;
|
||||||
|
}
|
||||||
|
|
||||||
#define UNIVERSE_TO_DISPX(ux) \
|
#define MAP_FIT_X ((MAX_X_UNIVERSE + 1) / SIS_SCREEN_WIDTH + 1)
|
||||||
(COORD)(((((long)(ux) - pMenuState->flash_rect1.corner.x) \
|
|
||||||
<< LOBYTE (pMenuState->delta_item)) \
|
static inline COORD
|
||||||
* SIS_SCREEN_WIDTH / (MAX_X_UNIVERSE + 1)) + ((SIS_SCREEN_WIDTH - 1) >> 1))
|
universeToDispx (COORD ux)
|
||||||
#define UNIVERSE_TO_DISPY(uy) \
|
{
|
||||||
(COORD)(((((long)pMenuState->flash_rect1.corner.y - (uy)) \
|
return signedDivWithError ((((long)ux - pMenuState->flash_rect1.corner.x)
|
||||||
<< LOBYTE (pMenuState->delta_item)) \
|
<< LOBYTE (pMenuState->delta_item))
|
||||||
* SIS_SCREEN_HEIGHT / (MAX_Y_UNIVERSE + 1)) + ((SIS_SCREEN_HEIGHT - 1) >> 1))
|
* SIS_SCREEN_WIDTH, MAX_X_UNIVERSE + MAP_FIT_X)
|
||||||
#define DISP_TO_UNIVERSEX(dx) \
|
+ ((SIS_SCREEN_WIDTH - 1) >> 1);
|
||||||
((COORD)((((long)((dx) - ((SIS_SCREEN_WIDTH - 1) >> 1)) \
|
}
|
||||||
* (MAX_X_UNIVERSE + 1)) >> LOBYTE (pMenuState->delta_item)) \
|
#define UNIVERSE_TO_DISPX(ux) universeToDispx(ux)
|
||||||
/ SIS_SCREEN_WIDTH) + pMenuState->flash_rect1.corner.x)
|
|
||||||
#define DISP_TO_UNIVERSEY(dy) \
|
static inline COORD
|
||||||
((COORD)((((long)(((SIS_SCREEN_HEIGHT - 1) >> 1) - (dy)) \
|
universeToDispy (COORD uy)
|
||||||
* (MAX_Y_UNIVERSE + 1)) >> LOBYTE (pMenuState->delta_item)) \
|
{
|
||||||
/ SIS_SCREEN_HEIGHT) + pMenuState->flash_rect1.corner.y)
|
return signedDivWithError ((((long)pMenuState->flash_rect1.corner.y - uy)
|
||||||
|
<< LOBYTE (pMenuState->delta_item))
|
||||||
|
* SIS_SCREEN_HEIGHT, MAX_Y_UNIVERSE + 2)
|
||||||
|
+ ((SIS_SCREEN_HEIGHT - 1) >> 1);
|
||||||
|
}
|
||||||
|
#define UNIVERSE_TO_DISPY(uy) universeToDispy(uy)
|
||||||
|
|
||||||
|
static inline COORD
|
||||||
|
dispxToUniverse (COORD dx)
|
||||||
|
{
|
||||||
|
return (((long)(dx - ((SIS_SCREEN_WIDTH - 1) >> 1))
|
||||||
|
* (MAX_X_UNIVERSE + MAP_FIT_X)) >> LOBYTE (pMenuState->delta_item))
|
||||||
|
/ SIS_SCREEN_WIDTH + pMenuState->flash_rect1.corner.x;
|
||||||
|
}
|
||||||
|
#define DISP_TO_UNIVERSEX(dx) dispxToUniverse(dx)
|
||||||
|
|
||||||
|
static inline COORD
|
||||||
|
dispyToUniverse (COORD dy)
|
||||||
|
{
|
||||||
|
return (((long)(((SIS_SCREEN_HEIGHT - 1) >> 1) - dy)
|
||||||
|
* (MAX_Y_UNIVERSE + 2)) >> LOBYTE (pMenuState->delta_item))
|
||||||
|
/ SIS_SCREEN_HEIGHT + pMenuState->flash_rect1.corner.y;
|
||||||
|
}
|
||||||
|
#define DISP_TO_UNIVERSEY(dy) dispyToUniverse(dy)
|
||||||
|
|
||||||
static BOOLEAN transition_pending;
|
static BOOLEAN transition_pending;
|
||||||
|
|
||||||
@@ -619,43 +654,29 @@ UpdateCursorLocation (MENU_STATE *pMS, int sx, int sy, const POINT *newpt)
|
|||||||
|
|
||||||
if (sx)
|
if (sx)
|
||||||
{
|
{
|
||||||
pMS->first_item.x =
|
pMS->first_item.x = DISP_TO_UNIVERSEX (s.origin.x) - sx;
|
||||||
DISP_TO_UNIVERSEX (s.origin.x) - sx;
|
|
||||||
while (UNIVERSE_TO_DISPX (pMS->first_item.x) == pt.x)
|
while (UNIVERSE_TO_DISPX (pMS->first_item.x) == pt.x)
|
||||||
{
|
|
||||||
pMS->first_item.x += sx;
|
pMS->first_item.x += sx;
|
||||||
|
|
||||||
if (pMS->first_item.x < 0)
|
if (pMS->first_item.x < 0)
|
||||||
{
|
|
||||||
pMS->first_item.x = 0;
|
pMS->first_item.x = 0;
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (pMS->first_item.x > MAX_X_UNIVERSE)
|
else if (pMS->first_item.x > MAX_X_UNIVERSE)
|
||||||
{
|
|
||||||
pMS->first_item.x = MAX_X_UNIVERSE;
|
pMS->first_item.x = MAX_X_UNIVERSE;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.origin.x = UNIVERSE_TO_DISPX (pMS->first_item.x);
|
s.origin.x = UNIVERSE_TO_DISPX (pMS->first_item.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sy)
|
if (sy)
|
||||||
{
|
{
|
||||||
pMS->first_item.y =
|
pMS->first_item.y = DISP_TO_UNIVERSEY (s.origin.y) + sy;
|
||||||
DISP_TO_UNIVERSEY (s.origin.y) + sy;
|
|
||||||
while (UNIVERSE_TO_DISPY (pMS->first_item.y) == pt.y)
|
while (UNIVERSE_TO_DISPY (pMS->first_item.y) == pt.y)
|
||||||
{
|
|
||||||
pMS->first_item.y -= sy;
|
pMS->first_item.y -= sy;
|
||||||
|
|
||||||
if (pMS->first_item.y < 0)
|
if (pMS->first_item.y < 0)
|
||||||
{
|
|
||||||
pMS->first_item.y = 0;
|
pMS->first_item.y = 0;
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (pMS->first_item.y > MAX_Y_UNIVERSE)
|
else if (pMS->first_item.y > MAX_Y_UNIVERSE)
|
||||||
{
|
|
||||||
pMS->first_item.y = MAX_Y_UNIVERSE;
|
pMS->first_item.y = MAX_Y_UNIVERSE;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.origin.y = UNIVERSE_TO_DISPY (pMS->first_item.y);
|
s.origin.y = UNIVERSE_TO_DISPY (pMS->first_item.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -707,6 +728,19 @@ UpdateCursorInfo (MENU_STATE *pMS, UNICODE *prevbuf)
|
|||||||
pMS->first_item = BestSDPtr->star_pt;
|
pMS->first_item = BestSDPtr->star_pt;
|
||||||
GetClusterName (BestSDPtr, buf);
|
GetClusterName (BestSDPtr, buf);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{ // No star found. Reset the coordinates to the cursor's location
|
||||||
|
pMS->first_item.x = DISP_TO_UNIVERSEX (pt.x);
|
||||||
|
if (pMS->first_item.x < 0)
|
||||||
|
pMS->first_item.x = 0;
|
||||||
|
else if (pMS->first_item.x > MAX_X_UNIVERSE)
|
||||||
|
pMS->first_item.x = MAX_X_UNIVERSE;
|
||||||
|
pMS->first_item.y = DISP_TO_UNIVERSEY (pt.y);
|
||||||
|
if (pMS->first_item.y < 0)
|
||||||
|
pMS->first_item.y = 0;
|
||||||
|
else if (pMS->first_item.y > MAX_Y_UNIVERSE)
|
||||||
|
pMS->first_item.y = MAX_Y_UNIVERSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (GET_GAME_STATE (ARILOU_SPACE))
|
if (GET_GAME_STATE (ARILOU_SPACE))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user