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...
This commit is contained in:
2024-04-24 15:53:49 -04:00
parent 703bc6114e
commit 2a4d7f40e2
+59 -5
View File
@@ -48,7 +48,7 @@
/* Thrusters increase this and decrease THRUST_WAIT based on /* Thrusters increase this and decrease THRUST_WAIT based on
* THRUST_INCREMENT, see InitDriveSlots near the bottom of this file * THRUST_INCREMENT, see InitDriveSlots near the bottom of this file
* for details. */ * for details. */
#define THRUST_INCREMENT 5 #define THRUST_INCREMENT 8
#define THRUST_WAIT 6 #define THRUST_WAIT 6
#define TURN_WAIT 17 #define TURN_WAIT 17
/* Turning jets decrease by 2 each */ /* Turning jets decrease by 2 each */
@@ -224,6 +224,8 @@ sis_hyper_preprocess (ELEMENT *ElementPtr)
SIZE dx = 0, dy = 0; SIZE dx = 0, dy = 0;
SIZE AccelerateDirection; SIZE AccelerateDirection;
STARSHIP *StarShipPtr; STARSHIP *StarShipPtr;
static bool halted= false;
static bool halting= false;
if (ElementPtr->state_flags & APPEARING) if (ElementPtr->state_flags & APPEARING)
ElementPtr->velocity = GLOBAL (velocity); ElementPtr->velocity = GLOBAL (velocity);
@@ -237,6 +239,7 @@ sis_hyper_preprocess (ELEMENT *ElementPtr)
|| (StarShipPtr->cur_status_flags & (LEFT | RIGHT | THRUST))) || (StarShipPtr->cur_status_flags & (LEFT | RIGHT | THRUST)))
{ {
LeaveAutoPilot: LeaveAutoPilot:
halting= false;
(GLOBAL (autopilot)).x = (GLOBAL (autopilot)).x =
(GLOBAL (autopilot)).y = ~0; (GLOBAL (autopilot)).y = ~0;
if (!(StarShipPtr->cur_status_flags & THRUST) if (!(StarShipPtr->cur_status_flags & THRUST)
@@ -246,8 +249,13 @@ LeaveAutoPilot:
AccelerateDirection = -1; AccelerateDirection = -1;
GetCurrentVelocityComponents (&ElementPtr->velocity, GetCurrentVelocityComponents (&ElementPtr->velocity,
&dx, &dy); &dx, &dy);
udx = dx << 4; if( false && !( StarShipPtr->cur_status_flags & THRUST ) ) halting= true;
udy = dy << 4; else
{
udx = dx << 4;
udy = dy << 4;
halted= false;
}
StarShipPtr->cur_status_flags &= ~THRUST; StarShipPtr->cur_status_flags &= ~THRUST;
} }
@@ -256,6 +264,7 @@ LeaveAutoPilot:
{ {
SIZE facing; SIZE facing;
POINT universe; POINT universe;
halting= halted= false;
universe.x = LOGX_TO_UNIVERSE (GLOBAL_SIS (log_x)); universe.x = LOGX_TO_UNIVERSE (GLOBAL_SIS (log_x));
universe.y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y)); universe.y = LOGY_TO_UNIVERSE (GLOBAL_SIS (log_y));
@@ -362,13 +371,58 @@ LeaveAutoPilot:
} }
} }
dx = (SIZE)((long)udx * speed / (long)dist); fprintf( stderr, "ADAM (PRE-PASS): I see dx:%d, dy:%d\n", dx, dy );
dy = (SIZE)((long)udy * speed / (long)dist); 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); SetVelocityComponents (&ElementPtr->velocity, dx, dy);
ElementPtr->thrust_wait = ElementPtr->thrust_wait =
StarShipPtr->RaceDescPtr->characteristics.thrust_wait; StarShipPtr->RaceDescPtr->characteristics.thrust_wait;
} }
if( false && halted )
{
AccelerateDirection = 0;
dx= dy= 0;
}
} }
static void static void