Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,4 +461,6 @@ enum PLACE { FIRST_PLACE, SECOND_PLACE, THIRD_PLACE, FOURTH_PLACE };
*
*/
#define MIN_LAPS 0
#define MAX_LAPS 3
#define MAX_LAPS CVarGetInteger("gNumLaps", 3)
#define FINAL_LAP (MAX_LAPS - 1)
#define FIFTH_LAP (MAX_LAPS + 2)
20 changes: 10 additions & 10 deletions src/code_80005FD0.c
Original file line number Diff line number Diff line change
Expand Up @@ -1212,11 +1212,11 @@ bool func_800088D8(s32 playerId, s16 lapNum, s16 arg2) {
if (gModeSelection == TIME_TRIALS) {
return true;
}
if (lapNum < 0) {
if (lapNum < MIN_LAPS) {
return true;
}
if (lapNum >= 4) {
lapNum = 3;
if (lapNum > MAX_LAPS) {
lapNum = MAX_LAPS;
}
if (D_80163330[playerId] == 1) {
return true;
Expand All @@ -1235,7 +1235,7 @@ bool func_800088D8(s32 playerId, s16 lapNum, s16 arg2) {
if (progress < 0) {
progress = -progress;
}
if (lapNum < 3) {
if (lapNum < MAX_LAPS) {
STEMP_V0 = temp_a3[0];
STEMP_V1 = temp_a3[8];
interp = gLapCompletionPercentByPlayerId[playerId];
Expand All @@ -1262,7 +1262,7 @@ bool func_800088D8(s32 playerId, s16 lapNum, s16 arg2) {
if (progress < 0) {
progress = -progress;
}
if (lapNum < 3) {
if (lapNum < MAX_LAPS) {
STEMP_V0 = temp_a3[0];
STEMP_V1 = temp_a3[8];
interp = gLapCompletionPercentByPlayerId[playerId];
Expand Down Expand Up @@ -1310,7 +1310,7 @@ bool func_800088D8(s32 playerId, s16 lapNum, s16 arg2) {
if ((var_t1 < 0) || (var_t1 >= 8)) {
return false;
}
if (lapNum < 3) {
if (lapNum < MAX_LAPS) {
STEMP_V0 = temp_a3[var_t1 + 0];
STEMP_V1 = temp_a3[var_t1 + 8];
interp = gLapCompletionPercentByPlayerId[playerId];
Expand Down Expand Up @@ -1481,7 +1481,7 @@ void update_player_path_completion(s32 playerId, Player* player) {
if (playerX < 300.0f) {
var_v1 = 1;
var_t0 = 1;
} else if ((playerX < 1300.0f) && (gLapCountByPlayerId[playerId] < 2) && ((D_801634EC == 1))) {
} else if ((playerX < 1300.0f) && (gLapCountByPlayerId[playerId] < FINAL_LAP) && ((D_801634EC == 1))) {
var_v1 = 1;
var_t0 = 1;
}
Expand All @@ -1490,7 +1490,7 @@ void update_player_path_completion(s32 playerId, Player* player) {
var_v1 = 1;
var_t0 = 1;
} else {
if ((playerX > -1300.0f) && (gLapCountByPlayerId[playerId] < 2) && (D_801634EC == 1)) {
if ((playerX > -1300.0f) && (gLapCountByPlayerId[playerId] < FINAL_LAP) && (D_801634EC == 1)) {
var_v1 = 1;
var_t0 = 1;
}
Expand All @@ -1504,7 +1504,7 @@ void update_player_path_completion(s32 playerId, Player* player) {
if ((var_v1 != 0) && (playerZ <= gPathStartZ)) {
if (gPathStartZ < previousPlayerZ) {
gLapCountByPlayerId[playerId]++;
if ((gModeSelection == GRAND_PRIX) && (gLapCountByPlayerId[playerId] == 5)) {
if ((gModeSelection == GRAND_PRIX) && (gLapCountByPlayerId[playerId] == FIFTH_LAP)) {
if (gGPCurrentRaceRankByPlayerIdDup[playerId] == 7) {
// clang-format off
for (var_v0 = 0; var_v0 < NUM_PLAYERS; var_v0++) { gLapCountByPlayerId[var_v0]--; } // has to be one line to match
Expand Down Expand Up @@ -7114,7 +7114,7 @@ void cpu_use_item_strategy(s32 playerId) {
gGPCurrentRaceRankByPlayerId[playerId]));
// Stock CPU Items
} else if ((((playerId * 20) + 100) < gNumPathPointsTraversed[playerId]) && (cpuStrategy->timer >= 0x259) &&
(cpuStrategy->numItemUse < 3) && (gLapCountByPlayerId[playerId] < 3)) {
(cpuStrategy->numItemUse < 3) && (gLapCountByPlayerId[playerId] < MAX_LAPS)) {
cpu_decisions_branch_item(
playerId, &cpuStrategy->branch,
cpu_gen_random_item((s16) gLapCountByPlayerId[playerId], gGPCurrentRaceRankByPlayerId[playerId]));
Expand Down
85 changes: 64 additions & 21 deletions src/code_80057C60.c
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ void func_80059358(void) {
void render_hud_2p_horizontal_player_two_horizontal_player_one(void) {
if (gHUDDisable == 0) {
render_hud_timer(PLAYER_ONE);
if (playerHUD[PLAYER_ONE].lapCount != 3) {
if (playerHUD[PLAYER_ONE].lapCount != MAX_LAPS) {
draw_hud_2d_texture_32x8(playerHUD[PLAYER_ONE].lapX, playerHUD[PLAYER_ONE].lapY,
(u8*) common_texture_hud_lap); // draw the lap word
draw_lap_count(playerHUD[PLAYER_ONE].lapX + 0xC, playerHUD[PLAYER_ONE].lapY - 4,
Expand All @@ -1082,7 +1082,7 @@ void func_800593F0(void) {
void render_hud_2p_horizontal_player_two(void) {
if (gHUDDisable == 0) {
render_hud_timer(PLAYER_TWO);
if (playerHUD[PLAYER_TWO].lapCount != 3) {
if (playerHUD[PLAYER_TWO].lapCount != MAX_LAPS) {
draw_hud_2d_texture_32x8(playerHUD[PLAYER_TWO].lapX, playerHUD[PLAYER_TWO].lapY,
(u8*) common_texture_hud_lap);
draw_lap_count(playerHUD[PLAYER_TWO].lapX + 0xC, playerHUD[PLAYER_TWO].lapY - 4,
Expand Down Expand Up @@ -1472,7 +1472,7 @@ void func_8005A14C(s32 playerId) {
} else {
gObjectList[objectIndex].primAlpha = 0x00FF;
}
if (lapCount >= 3) {
if (lapCount >= MAX_LAPS) {
gObjectList[objectIndex].direction_angle[2] = 0;
gObjectList[objectIndex].direction_angle[1] = 0;
gObjectList[objectIndex].direction_angle[0] = 0;
Expand Down Expand Up @@ -2571,7 +2571,7 @@ void func_8005CB60(s32 playerId, s32 lapCount) {
}
playerHUD[playerId].someTimer1 = playerHUD[playerId].lapDurations[*huh];
playerHUD[playerId].blinkTimer = 0x003C;
if (lapCount == 3) {
if (lapCount == MAX_LAPS) {
playerHUD[playerId].someTimer = playerHUD[playerId].lapCompletionTimes[*huh];
}
if (gModeSelection == (s32) 1) {
Expand All @@ -2584,7 +2584,7 @@ void func_8005CB60(s32 playerId, s32 lapCount) {
D_80165658[lapCount - 1] = 1;
D_801657E3 = 1;
}
if ((lapCount == 3) && ((u32) playerHUD[playerId].someTimer < (u32) D_80165648)) {
if ((lapCount == MAX_LAPS) && ((u32) playerHUD[playerId].someTimer < (u32) D_80165648)) {
D_801657E5 = 1;
}
}
Expand All @@ -2594,21 +2594,20 @@ void func_8005CB60(s32 playerId, s32 lapCount) {
}
*huhthedeuce += 1;
if (1) {}
switch (*huhthedeuce) { /* switch 1; irregular */
case 0: /* switch 1 */
break;
case 1: /* switch 1 */
CM_ActivateSecondLapLakitu(playerId); // func_80079084(playerId);
func_800C9060(playerId, SOUND_ARG_LOAD(0x19, 0x00, 0xF0, 0x15));
if ((IsLuigiRaceway()) && (D_80165898 == 0) && (gModeSelection != (s32) TIME_TRIALS)) {
D_80165898 = 1;
}
break;
case 2: /* switch 1 */
CM_ActivateFinalLapLakitu(playerId); // func_800790B4(playerId);
break;
case 3: /* switch 1 */
if ((D_8018D114 == 0) || (D_8018D114 == 1)) {

// Activate lakitu:second_lap if completed lap one and there's more than two total laps.
if ((*huhthedeuce == 1) && (MAX_LAPS > 2)) {
CM_ActivateSecondLapLakitu(playerId); // func_80079084(playerId);
func_800C9060(playerId, SOUND_ARG_LOAD(0x19, 0x00, 0xF0, 0x15));
if ((IsLuigiRaceway()) && (D_80165898 == 0) && (gModeSelection != (s32) TIME_TRIALS)) {
D_80165898 = 1;
}
// Activate lakitu:final_lap if completed the second last lap and there's more than one total laps.
} else if ((*huhthedeuce == FINAL_LAP) && (MAX_LAPS > 1)) {
CM_ActivateFinalLapLakitu(playerId); // func_800790B4(playerId);
// Activate lakitu:finished_race on completion of all laps.
} else if (*huhthedeuce == MAX_LAPS) {
if ((D_8018D114 == 0) || (D_8018D114 == 1)) {
gHUDModes = 0;
D_801657E6 = 0;
D_801657F0 = 0;
Expand Down Expand Up @@ -2636,8 +2635,52 @@ void func_8005CB60(s32 playerId, s32 lapCount) {
D_8018D1CC = 0x00000064;
}
}
break;
}

// switch (*huhthedeuce) { /* switch 1; irregular */
// case 0: /* switch 1 */
// break;
// case 1: /* switch 1 */
// CM_ActivateSecondLapLakitu(playerId); // func_80079084(playerId);
// func_800C9060(playerId, SOUND_ARG_LOAD(0x19, 0x00, 0xF0, 0x15));
// if ((IsLuigiRaceway()) && (D_80165898 == 0) && (gModeSelection != (s32) TIME_TRIALS)) {
// D_80165898 = 1;
// }
// break;
// case 2: /* switch 1 */
// CM_ActivateFinalLapLakitu(playerId); // func_800790B4(playerId);
// break;
// case 3: /* switch 1 */
// if ((D_8018D114 == 0) || (D_8018D114 == 1)) {
// gHUDModes = 0;
// D_801657E6 = 0;
// D_801657F0 = 0;
// D_801657E8 = 1;
// D_80165800[0] = 1;
// D_80165800[1] = 1;
// D_8018D204 = (s32) 1;
// }
// playerHUD[playerId].raceCompleteBool = 1;
// if (D_8018D114 == 2) {
// D_80165800[playerId] = 0;
// }
// if (IsYoshiValley()) {
// playerHUD[playerId].unk_81 = 1;
// }
// playerHUD[playerId].lap1CompletionTimeX = 0x0140;
// playerHUD[playerId].lap2CompletionTimeX = 0x01E0;
// playerHUD[playerId].lap3CompletionTimeX = 0x0280;
// playerHUD[playerId].totalTimeX = 0x0320;
// D_8016587C = (s32) 1;
// if (D_8018D20C == 0) {
// CM_ActivateFinishLakitu(playerId); // func_80079054(playerId);
// D_8018D20C = 1;
// if (gPlayerCount == (s8) 1) {
// D_8018D1CC = 0x00000064;
// }
// }
// break;
// }
}
} else {
f32_step_towards(&playerHUD[playerId].rankScaling, 1.0f, 0.125f);
Expand Down
2 changes: 1 addition & 1 deletion src/code_8006E9C0.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ void func_8006FA94(void) {
gHUDDisable = D_8018D214;
D_801657AE = gHUDDisable;
D_8018D20C = 0;
D_8018D320 = 3;
D_8018D320 = MAX_LAPS;
D_8018D2AC = 0;
D_8018D2BC = 0;
D_8018D2B4 = D_8018D2BC;
Expand Down
4 changes: 2 additions & 2 deletions src/engine/objects/Lakitu.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
*/
class OLakitu : public OObject {
public:
enum LakituType : uint32_t {
class enum LakituType : uint32_t {

Check failure on line 24 in src/engine/objects/Lakitu.h

View workflow job for this annotation

GitHub Actions / build (Debug)

declaration of anonymous class must be a definition

Check failure on line 24 in src/engine/objects/Lakitu.h

View workflow job for this annotation

GitHub Actions / build (Debug)

declaration of anonymous class must be a definition

Check failure on line 24 in src/engine/objects/Lakitu.h

View workflow job for this annotation

GitHub Actions / build (Debug)

declaration of anonymous class must be a definition
STARTER = 1,
FINISH, // Checkered flag
TOW, // Picks up an out of bounds player
SECOND_LAP,
FINAL_LAP,
BHV_FINAL_LAP,
REVERSE,
TOW_ICE_CUBE, // Picks up an out of bounds player in sherbet land as an ice-cube
};
Expand All @@ -37,9 +37,9 @@
};

public:
explicit OLakitu(s32 playerId, LakituType type);

Check failure on line 40 in src/engine/objects/Lakitu.h

View workflow job for this annotation

GitHub Actions / build (Debug)

unknown type name 'LakituType'; did you mean 'LakituTowType'?

Check failure on line 40 in src/engine/objects/Lakitu.h

View workflow job for this annotation

GitHub Actions / build (Debug)

unknown type name 'LakituType'; did you mean 'LakituTowType'?

Check failure on line 40 in src/engine/objects/Lakitu.h

View workflow job for this annotation

GitHub Actions / build (Debug)

unknown type name 'LakituType'; did you mean 'LakituTowType'?

void Activate(LakituType type); // Triggers Lakitu into a behaviour

Check failure on line 42 in src/engine/objects/Lakitu.h

View workflow job for this annotation

GitHub Actions / build (Debug)

unknown type name 'LakituType'; did you mean 'LakituTowType'?

Check failure on line 42 in src/engine/objects/Lakitu.h

View workflow job for this annotation

GitHub Actions / build (Debug)

unknown type name 'LakituType'; did you mean 'LakituTowType'?

virtual void Tick() override;
virtual void Tick60fps() override;
Expand Down Expand Up @@ -77,6 +77,6 @@
void func_8007AA44(s32 playerId); // animate lakitu

private:
LakituType _type;

Check failure on line 80 in src/engine/objects/Lakitu.h

View workflow job for this annotation

GitHub Actions / build (Debug)

unknown type name 'LakituType'; did you mean 'LakituTowType'?

Check failure on line 80 in src/engine/objects/Lakitu.h

View workflow job for this annotation

GitHub Actions / build (Debug)

unknown type name 'LakituType'; did you mean 'LakituTowType'?
s32 _playerId;
};
2 changes: 1 addition & 1 deletion src/port/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ void CM_ActivateFinalLapLakitu(s32 playerId) {
if ((gDemoMode) || (gGamestate == CREDITS_SEQUENCE)) {
return;
}
gWorldInstance.Lakitus[playerId]->Activate(OLakitu::LakituType::FINAL_LAP);
gWorldInstance.Lakitus[playerId]->Activate(OLakitu::LakituType::BHV_FINAL_LAP);
}

void CM_ActivateReverseLakitu(s32 playerId) {
Expand Down
6 changes: 3 additions & 3 deletions src/port/ui/PortMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ void PortMenu::AddRulesets() {
AddSidebarEntry("Enhancements", "Rulesets", 3);

// Requires more testing
// AddWidget(path, "Number of Laps", WIDGET_CVAR_SLIDER_INT)
// .CVar("gNumLaps")
// .Options(UIWidgets::IntSliderOptions().Min().Max(20).Step(1).DefaultValue(3));
AddWidget(path, "Number of Laps", WIDGET_CVAR_SLIDER_INT)
.CVar("gNumLaps")
.Options(UIWidgets::IntSliderOptions().Min(1).Max(20).Step(1).DefaultValue(3));

AddWidget(path, "No Itemboxes", WIDGET_CVAR_CHECKBOX)
.CVar("gDisableItemboxes")
Expand Down
16 changes: 8 additions & 8 deletions src/racing/race_logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void func_8028E298(void) {
}
temp_a2 = gPathIndexByPlayerId[i];

temp_v0 = ((2 - gPlayers[i].lapCount) * gPathCountByPathIndex[temp_a2]);
temp_v0 = ((FINAL_LAP - gPlayers[i].lapCount) * gPathCountByPathIndex[temp_a2]);
temp_v0 += gPathCountByPathIndex[temp_a2] * (1.0f - gLapCompletionPercentByPlayerId[i]);
temp_v0 /= 15.0f;

Expand Down Expand Up @@ -491,7 +491,7 @@ void func_8028EF28(void) {
gPlayers[i].lapCount++;

if ((gPlayers[i].type & PLAYER_HUMAN) != 0) {
if (gPlayers[i].lapCount == 3) {
if (gPlayers[i].lapCount == MAX_LAPS) {
func_8028EEF0(i);

currentPosition = gPlayers[i].currentRank;
Expand Down Expand Up @@ -572,7 +572,7 @@ void func_8028EF28(void) {
}
}

} else if (gPlayers[i].lapCount == 2) {
} else if (gPlayers[i].lapCount == FINAL_LAP) {
if ((gPlayers[i].type & 0x100) != 0) {
return;
}
Expand All @@ -581,7 +581,7 @@ void func_8028EF28(void) {
func_800CA49C((u8) i);
}
}
} else if (gPlayers[i].lapCount == 3) {
} else if (gPlayers[i].lapCount == MAX_LAPS) {
func_8028EEF0(i);
if (gModeSelection == TIME_TRIALS) {
func_80005AE8(player);
Expand Down Expand Up @@ -798,19 +798,19 @@ void func_8028F970(void) {
if (gEnableDebugMode) {
if (gModeSelection != BATTLE) { // Skip laps
if (gControllerOne->buttonPressed & U_JPAD) {
gLapCountByPlayerId[0] = 2;
gLapCountByPlayerId[0] = FINAL_LAP;
play_sound2(SOUND_MENU_OPTION);
printf("[race_logic.c] [func_8028F970] Skipped laps for player 1\n");
}
if (gControllerOne->buttonPressed & R_JPAD) {
gLapCountByPlayerId[0] = 2;
gLapCountByPlayerId[1] = 2;
gLapCountByPlayerId[0] = FINAL_LAP;
gLapCountByPlayerId[1] = FINAL_LAP;
play_sound2(SOUND_MENU_OPTION);
printf("[race_logic.c] [func_8028F970] Skipped laps for players 1 & 2\n");
}
if (gControllerOne->buttonPressed & D_JPAD) {
for (size_t i = 0; i < NUM_PLAYERS; i++) {
gLapCountByPlayerId[i] = 2;
gLapCountByPlayerId[i] = FINAL_LAP;
}
play_sound2(SOUND_MENU_OPTION);
printf("[race_logic.c] [func_8028F970] Skipped laps for all players\n");
Expand Down
Loading
Loading