diff --git a/sc2/ChangeLog b/sc2/ChangeLog index c4180d093..bad307e1b 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ 0.2: +- Starmap fuel range calculator and actual consumption matches now - Collision detection is now pixel-perfect (fixes Sa-Matra, BUTT missile, etc) - Fixed lander position sign bug which was introduced by previous fixes - Initial display of planet surface on landing is at correct position diff --git a/sc2/TODO b/sc2/TODO index b17bda9d3..5d8c1cac4 100644 --- a/sc2/TODO +++ b/sc2/TODO @@ -83,8 +83,6 @@ Glitches (don't crash the game, medium priority): - lander speed varies per computer - "device used successfully" and "device usage failed" sounds are identical (the failure one) -- The fuel range calculator on the starmap does not work correctly. - Estimate too small. May be a rounding error. - spathi blink and other spathi animation may go out of sync - subtitles may go past the bottom boundary - If you win a Melee, and then are blown up yourself, the sound loops diff --git a/sc2/src/sc2code/hyper.c b/sc2/src/sc2code/hyper.c index 35a7de2dc..bd5944bff 100644 --- a/sc2/src/sc2code/hyper.c +++ b/sc2/src/sc2code/hyper.c @@ -31,7 +31,7 @@ void WaitForNoInput (SIZE Duration); static FRAME hyperstars[3]; static COLORMAP hypercmaps[2]; static BYTE fuel_ticks; -static COUNT hyper_dx, hyper_dy; +static COUNT hyper_dx, hyper_dy, hyper_extra; void MoveSIS (PSIZE pdx, PSIZE pdy) @@ -94,6 +94,7 @@ MoveSIS (PSIZE pdx, PSIZE pdy) { COUNT cur_fuel_ticks; COUNT hyper_dist; + DWORD adj_dx, adj_dy; if (new_dx < 0) new_dx = -new_dx; @@ -102,11 +103,14 @@ MoveSIS (PSIZE pdx, PSIZE pdy) new_dy = -new_dy; hyper_dy += new_dy; - hyper_dist = square_root ( - (DWORD)hyper_dx * hyper_dx - + (DWORD)hyper_dy * hyper_dy - ); + /* These macros are also used in the fuel estimate on the starmap. */ + adj_dx = LOGX_TO_UNIVERSE(16 * hyper_dx); + adj_dy = MAX_Y_UNIVERSE - LOGY_TO_UNIVERSE(16 * hyper_dy); + + hyper_dist = square_root (adj_dx * adj_dx + adj_dy * adj_dy) + + hyper_extra; cur_fuel_ticks = hyper_dist >> 4; + if (cur_fuel_ticks > (COUNT)fuel_ticks) { #ifndef TESTING @@ -114,7 +118,8 @@ MoveSIS (PSIZE pdx, PSIZE pdy) #endif /* TESTING */ if (cur_fuel_ticks > 0x00FF) { - hyper_dx = hyper_dist & ((1 << 4) - 1); + hyper_dx = 0; + hyper_extra = hyper_dist & ((1 << 4) - 1); hyper_dy = 0; cur_fuel_ticks = 0; } @@ -296,7 +301,7 @@ LoadHyperData (void) BOOLEAN LoadHyperspace (void) { - hyper_dx = hyper_dy = 0; + hyper_dx = hyper_dy = hyper_extra = 0; fuel_ticks = 1; GLOBAL (ShipStamp.origin.x) = -MAX_X_UNIVERSE;