Distinguish clearly the two enums related to speed

This commit is contained in:
cbt6 2021-11-03 02:51:30 +08:00
parent 3f5f057ebe
commit 3556024a06
2 changed files with 18 additions and 18 deletions

View File

@ -17,11 +17,11 @@ struct BikeHistoryInputInfo
// Player speeds
enum
{
SPEED_STANDING,
SPEED_NORMAL,
SPEED_FAST,
SPEED_FASTER,
SPEED_FASTEST,
BIKE_SPEED_STANDING,
BIKE_SPEED_NORMAL,
BIKE_SPEED_FAST,
BIKE_SPEED_FASTER,
BIKE_SPEED_FASTEST,
};
// mach bike transitions enum

View File

@ -108,7 +108,7 @@ static u8 (*const sAcroBikeInputHandlers[])(u8 *, u16, u16) =
};
// used with bikeFrameCounter from mach bike
static const u16 sMachBikeSpeeds[] = {SPEED_NORMAL, SPEED_FAST, SPEED_FASTEST};
static const u16 sMachBikeSpeeds[] = {BIKE_SPEED_NORMAL, BIKE_SPEED_FAST, BIKE_SPEED_FASTEST};
// this is a list of timers to compare against later, terminated with 0. the only timer being compared against is 4 frames in this list.
static const u8 sAcroBikeJumpTimerList[] = {4, 0};
@ -147,7 +147,7 @@ static u8 GetMachBikeTransition(u8 *dirTraveling)
if (*dirTraveling == 0)
{
*dirTraveling = direction; // update the direction, since below we either faced a direction or we started moving.
if (gPlayerAvatar.bikeSpeed == SPEED_STANDING)
if (gPlayerAvatar.bikeSpeed == BIKE_SPEED_STANDING)
{
gPlayerAvatar.runningState = NOT_MOVING;
return MACH_TRANS_FACE_DIRECTION;
@ -159,7 +159,7 @@ static u8 GetMachBikeTransition(u8 *dirTraveling)
// we need to check if the last traveled direction changed from the new direction as well as ensuring that we dont update the state while the player is moving: see the else check.
if (*dirTraveling != direction && gPlayerAvatar.runningState != MOVING)
{
if (gPlayerAvatar.bikeSpeed != SPEED_STANDING)
if (gPlayerAvatar.bikeSpeed != BIKE_SPEED_STANDING)
{
*dirTraveling = direction; // implement the new direction
gPlayerAvatar.runningState = MOVING;
@ -246,7 +246,7 @@ static void MachBikeTransition_TrySlowDown(u8 direction)
{
u8 collision;
if (gPlayerAvatar.bikeSpeed != SPEED_STANDING)
if (gPlayerAvatar.bikeSpeed != BIKE_SPEED_STANDING)
gPlayerAvatar.bikeFrameCounter = --gPlayerAvatar.bikeSpeed;
collision = GetBikeCollision(direction);
@ -306,7 +306,7 @@ static u8 AcroBikeHandleInputNormal(u8 *newDirection, u16 newKeys, u16 heldKeys)
return ACRO_TRANS_FACE_DIRECTION;
}
}
if (*newDirection == direction && (heldKeys & B_BUTTON) && gPlayerAvatar.bikeSpeed == SPEED_STANDING)
if (*newDirection == direction && (heldKeys & B_BUTTON) && gPlayerAvatar.bikeSpeed == BIKE_SPEED_STANDING)
{
gPlayerAvatar.bikeSpeed++;
gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_MOVING;
@ -342,7 +342,7 @@ static u8 AcroBikeHandleInputTurning(u8 *newDirection, u16 newKeys, u16 heldKeys
if (*newDirection == AcroBike_GetJumpDirection())
{
Bike_SetBikeStill(); // Bike_SetBikeStill sets speed to standing, but the next line immediately overrides it. could have just reset acroBikeState to 0 here instead of wasting a jump.
gPlayerAvatar.bikeSpeed = SPEED_NORMAL;
gPlayerAvatar.bikeSpeed = BIKE_SPEED_NORMAL;
if (*newDirection == GetOppositeDirection(direction))
{
// do a turn jump.
@ -775,7 +775,7 @@ static void AcroBike_TryHistoryUpdate(u16 newKeys, u16 heldKeys) // newKeys is u
else
{
Bike_UpdateDirTimerHistory(direction);
gPlayerAvatar.bikeSpeed = SPEED_STANDING;
gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING;
}
direction = heldKeys & (A_BUTTON | B_BUTTON | SELECT_BUTTON | START_BUTTON); // directions is reused for some reason.
@ -787,7 +787,7 @@ static void AcroBike_TryHistoryUpdate(u16 newKeys, u16 heldKeys) // newKeys is u
else
{
Bike_UpdateABStartSelectHistory(direction);
gPlayerAvatar.bikeSpeed = SPEED_STANDING;
gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING;
}
}
@ -994,7 +994,7 @@ void BikeClearState(int newDirHistory, int newAbStartHistory)
gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL;
gPlayerAvatar.newDirBackup = DIR_NONE;
gPlayerAvatar.bikeFrameCounter = 0;
gPlayerAvatar.bikeSpeed = SPEED_STANDING;
gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING;
gPlayerAvatar.directionHistory = newDirHistory;
gPlayerAvatar.abStartSelectHistory = newAbStartHistory;
@ -1014,7 +1014,7 @@ void Bike_UpdateBikeCounterSpeed(u8 counter)
static void Bike_SetBikeStill(void)
{
gPlayerAvatar.bikeFrameCounter = 0;
gPlayerAvatar.bikeSpeed = SPEED_STANDING;
gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING;
}
s16 GetPlayerSpeed(void)
@ -1027,11 +1027,11 @@ s16 GetPlayerSpeed(void)
if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE)
return machSpeeds[gPlayerAvatar.bikeFrameCounter];
else if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE)
return SPEED_FASTER;
return BIKE_SPEED_FASTER;
else if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_DASH))
return SPEED_FAST;
return BIKE_SPEED_FAST;
else
return SPEED_NORMAL;
return BIKE_SPEED_NORMAL;
}
void Bike_HandleBumpySlopeJump(void)