From 2a4d7f40e2e04d41a688a0161447757423b950c5 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Wed, 24 Apr 2024 15:53:49 -0400 Subject: [PATCH] Some hyperspace physics hacks... You can go faster in hyperspace, but because of the inertial calculations, it gets a bit janky in hyperspace slow-down... --- sc2/src/uqm/ships/sis_ship/sis_ship.c | 64 ++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/sc2/src/uqm/ships/sis_ship/sis_ship.c b/sc2/src/uqm/ships/sis_ship/sis_ship.c index 9512d76c5..fd24115eb 100644 --- a/sc2/src/uqm/ships/sis_ship/sis_ship.c +++ b/sc2/src/uqm/ships/sis_ship/sis_ship.c @@ -48,7 +48,7 @@ /* Thrusters increase this and decrease THRUST_WAIT based on * THRUST_INCREMENT, see InitDriveSlots near the bottom of this file * for details. */ -#define THRUST_INCREMENT 5 +#define THRUST_INCREMENT 8 #define THRUST_WAIT 6 #define TURN_WAIT 17 /* Turning jets decrease by 2 each */ @@ -224,6 +224,8 @@ sis_hyper_preprocess (ELEMENT *ElementPtr) SIZE dx = 0, dy = 0; SIZE AccelerateDirection; STARSHIP *StarShipPtr; + static bool halted= false; + static bool halting= false; if (ElementPtr->state_flags & APPEARING) ElementPtr->velocity = GLOBAL (velocity); @@ -237,6 +239,7 @@ sis_hyper_preprocess (ELEMENT *ElementPtr) || (StarShipPtr->cur_status_flags & (LEFT | RIGHT | THRUST))) { LeaveAutoPilot: + halting= false; (GLOBAL (autopilot)).x = (GLOBAL (autopilot)).y = ~0; if (!(StarShipPtr->cur_status_flags & THRUST) @@ -246,8 +249,13 @@ LeaveAutoPilot: AccelerateDirection = -1; GetCurrentVelocityComponents (&ElementPtr->velocity, &dx, &dy); - udx = dx << 4; - udy = dy << 4; + if( false && !( StarShipPtr->cur_status_flags & THRUST ) ) halting= true; + else + { + udx = dx << 4; + udy = dy << 4; + halted= false; + } StarShipPtr->cur_status_flags &= ~THRUST; } @@ -256,6 +264,7 @@ LeaveAutoPilot: { SIZE facing; POINT universe; + halting= halted= false; universe.x = LOGX_TO_UNIVERSE (GLOBAL_SIS (log_x)); universe.y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y)); @@ -362,13 +371,58 @@ LeaveAutoPilot: } } - dx = (SIZE)((long)udx * speed / (long)dist); - dy = (SIZE)((long)udy * speed / (long)dist); + fprintf( stderr, "ADAM (PRE-PASS): I see dx:%d, dy:%d\n", dx, dy ); + if( false && halting ) + { + if( !halted ) + { + if( false ) + { + if( dx <= 4 ) dx= 0; + if( dx > 4 ) dx= 4; + if( dx > 8 ) dx= 8; + if( dx > 12 ) dx= 12; + if( dx > 16 ) dx= 16; + + if( -dy <= 4 ) dy= -0; + if( -dy > 4 ) dy= -4; + if( -dy > 8 ) dy= -8; + if( -dy > 12 ) dy= -12; + if( -dy > 16 ) dy= -16; + } + else + { + if( dx != 0 ) dx/= 4; + //if( dx < 0 ) dx= 0; + + if( dy != 0 ) dy/= 4; + //if( dy > 0 ) dy= 0; + + } + fprintf( stderr, "ADAM (PASS): I see dx:%d, dy:%d\n", dx, dy ); + + if( dx == 0 && dy == 0 ) halted= true; + } + } + else + { + dx = (SIZE)((long)udx * speed / (long)dist); + dy = (SIZE)((long)udy * speed / (long)dist); + fprintf( stderr, "ADAM (STOCK): I see dx:%d, dy:%d\n", dx, dy ); + } + + fprintf( stderr, "ADAM: I see dx:%d, dy:%d\n", dx, dy ); SetVelocityComponents (&ElementPtr->velocity, dx, dy); ElementPtr->thrust_wait = StarShipPtr->RaceDescPtr->characteristics.thrust_wait; } + + if( false && halted ) + { + AccelerateDirection = 0; + dx= dy= 0; + } } static void