From 88dcb787676a959c23acd07db64723a96d0fb25a Mon Sep 17 00:00:00 2001 From: MegaMech Date: Sun, 20 Jul 2025 17:29:10 -0600 Subject: [PATCH 1/4] Impl MAX_LAPS --- include/defines.h | 2 +- src/code_80057C60.c | 80 ++++++++++++++++++++++++++++++---------- src/code_8006E9C0.c | 2 +- src/port/ui/PortMenu.cpp | 6 +-- src/racing/race_logic.c | 6 +-- src/render_objects.c | 10 ++--- 6 files changed, 73 insertions(+), 33 deletions(-) diff --git a/include/defines.h b/include/defines.h index 60c21af83b..e6a9810ddb 100644 --- a/include/defines.h +++ b/include/defines.h @@ -461,4 +461,4 @@ enum PLACE { FIRST_PLACE, SECOND_PLACE, THIRD_PLACE, FOURTH_PLACE }; * */ #define MIN_LAPS 0 -#define MAX_LAPS 3 +#define MAX_LAPS CVarGetInteger("gNumLaps", 3) diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 90fc552df8..c1cac5daab 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -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, @@ -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, @@ -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) { @@ -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; } } @@ -2594,21 +2594,17 @@ 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)) { + + if (*huhthedeuce == 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; + } + } else if (*huhthedeuce == MAX_LAPS - 1) { + CM_ActivateFinalLapLakitu(playerId); // func_800790B4(playerId); + } else if (*huhthedeuce == MAX_LAPS) { + if ((D_8018D114 == 0) || (D_8018D114 == 1)) { gHUDModes = 0; D_801657E6 = 0; D_801657F0 = 0; @@ -2636,8 +2632,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); diff --git a/src/code_8006E9C0.c b/src/code_8006E9C0.c index bb1e706dfc..efcb773a39 100644 --- a/src/code_8006E9C0.c +++ b/src/code_8006E9C0.c @@ -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; diff --git a/src/port/ui/PortMenu.cpp b/src/port/ui/PortMenu.cpp index 13ec40f516..8058df5ecd 100644 --- a/src/port/ui/PortMenu.cpp +++ b/src/port/ui/PortMenu.cpp @@ -435,9 +435,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().Max(20).Step(1).DefaultValue(3)); AddWidget(path, "No Itemboxes", WIDGET_CVAR_CHECKBOX) .CVar("gDisableItemboxes") diff --git a/src/racing/race_logic.c b/src/racing/race_logic.c index cd99ab4002..cd95755742 100644 --- a/src/racing/race_logic.c +++ b/src/racing/race_logic.c @@ -487,7 +487,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; @@ -568,7 +568,7 @@ void func_8028EF28(void) { } } - } else if (gPlayers[i].lapCount == 2) { + } else if (gPlayers[i].lapCount == MAX_LAPS - 1) { if ((gPlayers[i].type & 0x100) != 0) { return; } @@ -577,7 +577,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); diff --git a/src/render_objects.c b/src/render_objects.c index 89fad088e3..472708ea77 100644 --- a/src/render_objects.c +++ b/src/render_objects.c @@ -2630,13 +2630,13 @@ void func_8004E800(s32 playerId) { // @port: Tag the transform. FrameInterpolation_RecordOpenChild("Player place HUD", playerId); if (playerHUD[playerId].unk_81 != 0) { - if (playerHUD[playerId].lapCount != 3) { + if (playerHUD[playerId].lapCount != MAX_LAPS) { // Not the final lap func_8004A384(playerHUD[playerId].rankX + playerHUD[playerId].slideRankX, playerHUD[playerId].rankY + playerHUD[playerId].slideRankY, 0U, playerHUD[playerId].rankScaling, 0x000000FF, D_800E55F8[D_8018CF98[playerId]], 0, 0x000000FF, common_texture_hud_place[D_8018CF98[playerId]], D_0D0068F0, 0x00000080, 0x00000040, 0x00000080, 0x00000040); - } else { + } else { // final lap func_8004A384(playerHUD[playerId].rankX + playerHUD[playerId].slideRankX, playerHUD[playerId].rankY + playerHUD[playerId].slideRankY, 0U, playerHUD[playerId].rankScaling, 0x000000FF, D_800E55F8[D_80165594], 0, 0x000000FF, @@ -2650,14 +2650,14 @@ void func_8004E800(s32 playerId) { void func_8004E998(s32 playerId) { if (playerHUD[playerId].unk_81 != 0) { - if (playerHUD[playerId].lapCount != 3) { + if (playerHUD[playerId].lapCount != MAX_LAPS) { // Not the final lap func_8004A384(playerHUD[playerId].rankX + playerHUD[playerId].slideRankX, playerHUD[playerId].rankY + playerHUD[playerId].slideRankY, 0U, playerHUD[playerId].rankScaling, 0x000000FF, D_800E5618[gGPCurrentRaceRankByPlayerId[playerId]], 0, 0x000000FF, D_0D015258[gGPCurrentRaceRankByPlayerId[playerId]], D_0D006030, 0x00000040, 0x00000040, 0x00000040, 0x00000040); - } else { + } else { // The final lap func_8004A384(playerHUD[playerId].rankX + playerHUD[playerId].slideRankX, playerHUD[playerId].rankY + playerHUD[playerId].slideRankY, 0U, playerHUD[playerId].rankScaling, 0x000000FF, D_800E5618[D_80165598], 0, 0x000000FF, @@ -3332,7 +3332,7 @@ void func_80050E34(s32 playerId, s32 arg1) { spB8 = 0; } - if ((IsYoshiValley()) && (lapCount < 3)) { + if ((IsYoshiValley()) && (lapCount < MAX_LAPS)) { gSPDisplayList(gDisplayListHead++, D_0D007DB8); gDPLoadTLUT_pal256(gDisplayListHead++, common_tlut_portrait_bomb_kart_and_question_mark); rsp_load_texture(common_texture_portrait_question_mark, 0x00000020, 0x00000020); From ba4345d54f661e8d5eb7c7cdbd51b3124603bda3 Mon Sep 17 00:00:00 2001 From: MegaMech Date: Sun, 20 Jul 2025 17:49:36 -0600 Subject: [PATCH 2/4] Update code_80005FD0.c --- src/code_80005FD0.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index ed8781451d..a401a28abc 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -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 + 1) { + lapNum = MAX_LAPS; } if (D_80163330[playerId] == 1) { return true; @@ -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]; @@ -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]; @@ -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]; From 6d11517877e738732d30ef696225b9117aa3976e Mon Sep 17 00:00:00 2001 From: MegaMech Date: Sun, 20 Jul 2025 17:50:55 -0600 Subject: [PATCH 3/4] Update code_80057C60.c --- src/code_80057C60.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/code_80057C60.c b/src/code_80057C60.c index c1cac5daab..c398b288c8 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -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; From bff8b48f9059fc037776f81bdb759b3aea53c52c Mon Sep 17 00:00:00 2001 From: MegaMech Date: Tue, 29 Jul 2025 14:13:53 -0600 Subject: [PATCH 4/4] Fix any number of laps --- include/defines.h | 2 ++ src/code_80005FD0.c | 10 ++++---- src/code_80057C60.c | 7 ++++-- src/engine/objects/Lakitu.h | 4 ++-- src/port/Game.cpp | 2 +- src/port/ui/PortMenu.cpp | 2 +- src/racing/race_logic.c | 12 +++++----- src/render_objects.c | 48 ++++++++++++++++++------------------- src/replays.c | 14 +++++------ 9 files changed, 52 insertions(+), 49 deletions(-) diff --git a/include/defines.h b/include/defines.h index e6a9810ddb..ac328481d9 100644 --- a/include/defines.h +++ b/include/defines.h @@ -462,3 +462,5 @@ enum PLACE { FIRST_PLACE, SECOND_PLACE, THIRD_PLACE, FOURTH_PLACE }; */ #define MIN_LAPS 0 #define MAX_LAPS CVarGetInteger("gNumLaps", 3) +#define FINAL_LAP (MAX_LAPS - 1) +#define FIFTH_LAP (MAX_LAPS + 2) diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index a401a28abc..11286dad04 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -1215,7 +1215,7 @@ bool func_800088D8(s32 playerId, s16 lapNum, s16 arg2) { if (lapNum < MIN_LAPS) { return true; } - if (lapNum >= MAX_LAPS + 1) { + if (lapNum > MAX_LAPS) { lapNum = MAX_LAPS; } if (D_80163330[playerId] == 1) { @@ -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; } @@ -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; } @@ -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 @@ -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])); diff --git a/src/code_80057C60.c b/src/code_80057C60.c index c398b288c8..1defef17b0 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -2595,14 +2595,17 @@ void func_8005CB60(s32 playerId, s32 lapCount) { *huhthedeuce += 1; if (1) {} - if (*huhthedeuce == 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; } - } else if (*huhthedeuce == MAX_LAPS - 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; diff --git a/src/engine/objects/Lakitu.h b/src/engine/objects/Lakitu.h index 1944733ee9..df104345ac 100644 --- a/src/engine/objects/Lakitu.h +++ b/src/engine/objects/Lakitu.h @@ -21,12 +21,12 @@ extern "C" { */ class OLakitu : public OObject { public: - enum LakituType : uint32_t { + class enum LakituType : uint32_t { 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 }; diff --git a/src/port/Game.cpp b/src/port/Game.cpp index 62dec7a166..3f366a3b00 100644 --- a/src/port/Game.cpp +++ b/src/port/Game.cpp @@ -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) { diff --git a/src/port/ui/PortMenu.cpp b/src/port/ui/PortMenu.cpp index 5e111ea304..65142b58a4 100644 --- a/src/port/ui/PortMenu.cpp +++ b/src/port/ui/PortMenu.cpp @@ -435,7 +435,7 @@ void PortMenu::AddRulesets() { // Requires more testing AddWidget(path, "Number of Laps", WIDGET_CVAR_SLIDER_INT) .CVar("gNumLaps") - .Options(UIWidgets::IntSliderOptions().Min().Max(20).Step(1).DefaultValue(3)); + .Options(UIWidgets::IntSliderOptions().Min(1).Max(20).Step(1).DefaultValue(3)); AddWidget(path, "No Itemboxes", WIDGET_CVAR_CHECKBOX) .CVar("gDisableItemboxes") diff --git a/src/racing/race_logic.c b/src/racing/race_logic.c index a6e125532a..55dc2b36e3 100644 --- a/src/racing/race_logic.c +++ b/src/racing/race_logic.c @@ -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; @@ -572,7 +572,7 @@ void func_8028EF28(void) { } } - } else if (gPlayers[i].lapCount == MAX_LAPS - 1) { + } else if (gPlayers[i].lapCount == FINAL_LAP) { if ((gPlayers[i].type & 0x100) != 0) { return; } @@ -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"); diff --git a/src/render_objects.c b/src/render_objects.c index 47a778ab95..ab0ea53f36 100644 --- a/src/render_objects.c +++ b/src/render_objects.c @@ -3036,8 +3036,8 @@ void draw_lap_count(s16 lapX, s16 lapY, s8 lap) { gSPDisplayList(gDisplayListHead++, D_0D007EB8); } -void func_8004FDB4(f32 arg0, f32 arg1, s16 arg2, s16 arg3, s16 characterId, s32 arg5, s32 arg6, s32 arg7, s32 arg8) { - if ((IsYoshiValley()) && (arg3 < 3) && (arg8 == 0)) { +void func_8004FDB4(f32 arg0, f32 arg1, s16 arg2, s16 lapCount, s16 characterId, s32 arg5, s32 arg6, s32 arg7, s32 arg8) { + if ((IsYoshiValley()) && (lapCount < MAX_LAPS) && (arg8 == 0)) { func_80042330((s32) arg0, (s32) arg1, 0U, 1.0f); gSPDisplayList(gDisplayListHead++, D_0D007DB8); func_8004B35C(0x000000FF, 0x000000FF, 0x000000FF, D_8018D3E0); @@ -3045,7 +3045,7 @@ void func_8004FDB4(f32 arg0, f32 arg1, s16 arg2, s16 arg3, s16 characterId, s32 rsp_load_texture(common_texture_portrait_question_mark, 0x00000020, 0x00000020); gSPDisplayList(gDisplayListHead++, D_0D0069E0); } else { - func_80042330_portrait(arg0, arg1, 0U, 1.0f, arg3); + func_80042330_portrait(arg0, arg1, 0U, 1.0f, lapCount); gSPDisplayList(gDisplayListHead++, D_0D007DB8); func_8004B35C(0x000000FF, 0x000000FF, 0x000000FF, arg5); gDPLoadTLUT_pal256(gDisplayListHead++, gPortraitTLUTs[characterId]); @@ -3056,7 +3056,7 @@ void func_8004FDB4(f32 arg0, f32 arg1, s16 arg2, s16 arg3, s16 characterId, s32 gSPDisplayList(gDisplayListHead++, D_0D0069E0); } if (arg6 != 0) { - func_80042330_portrait(arg0, arg1, 0U, 1.0f, arg3); + func_80042330_portrait(arg0, arg1, 0U, 1.0f, lapCount); gSPDisplayList(gDisplayListHead++, D_0D007A60); func_8004B35C(D_8018D3E4, D_8018D3E8, D_8018D3EC, 0x000000FF); func_80044924(common_texture_character_portrait_border, 0x20, 0x20); @@ -3068,9 +3068,9 @@ void func_8004FDB4(f32 arg0, f32 arg1, s16 arg2, s16 arg3, s16 characterId, s32 gDPLoadTLUT_pal256(gDisplayListHead++, common_tlut_hud_type_C_rank_font); rsp_load_texture(common_texture_hud_type_C_rank_font[arg2], 0x00000010, 0x00000010); if (arg7 != 0) { - func_80042330_portrait((s32) (arg0 + 9.0f), (s32) (arg1 + 7.0f), 0U, 1.0f, arg3); + func_80042330_portrait((s32) (arg0 + 9.0f), (s32) (arg1 + 7.0f), 0U, 1.0f, lapCount); } else { - func_80042330_portrait((s32) (arg0 - 9.0f), (s32) (arg1 + 7.0f), 0U, 1.0f, arg3); + func_80042330_portrait((s32) (arg0 - 9.0f), (s32) (arg1 + 7.0f), 0U, 1.0f, lapCount); } gSPDisplayList(gDisplayListHead++, D_0D006980); } @@ -3139,11 +3139,11 @@ void func_80050320(void) { s32 func_80050644(u16 arg0, s32* arg1, s32* arg2) { s32 var_v0 = 0; s32 thing = 0; - s32 test = gLapCountByPlayerId[arg0]; + s32 lapCount = gLapCountByPlayerId[arg0]; - if (test < 3) { + if (lapCount < MAX_LAPS) { if (gPlayerCountSelection1 == 1) { - if (test >= 0) { + if (lapCount >= 0) { thing = (s32) (gLapCompletionPercentByPlayerId[arg0] * 928); } if (thing < 0x104) { @@ -3164,7 +3164,7 @@ s32 func_80050644(u16 arg0, s32* arg1, s32* arg2) { var_v0 = 4; } } else { - if (test >= 0) { + if (lapCount >= 0) { thing = (s32) (gLapCompletionPercentByPlayerId[arg0] * 260); } *arg1 = thing; @@ -3207,7 +3207,7 @@ void func_800508C0(void) { s32 sp54; s32 sp50; s32 sp4C; - s32 temp_v1; + s32 lapCount; s16 var_s0; UNUSED s16 stackPadding; u16 var_s0_2; @@ -3220,32 +3220,30 @@ void func_800508C0(void) { var_s0 = gGPCurrentRacePlayerIdByRank[0]; } sp4C = func_80050644(var_s0, &sp54, &sp50); - temp_v1 = gLapCountByPlayerId[var_s0]; - if (temp_v1 > 0) { - if (temp_v1 == 1) { + lapCount = gLapCountByPlayerId[var_s0]; + if (lapCount > 0) { + if ((lapCount == 1) && (MAX_LAPS > 2)) { var_s0_2 = 0; var_s1 = 0; var_s2 = 0x000000FF; + } else if ((lapCount == FINAL_LAP) && (MAX_LAPS > 1)) { + var_s0_2 = 0x00FF; + var_s1 = 0x000000FF; + var_s2 = 0; } else { - if (temp_v1 == 2) { - var_s0_2 = 0x00FF; - var_s1 = 0x000000FF; - var_s2 = 0; - } else { - var_s0_2 = 0x00FF; - var_s1 = 0; - var_s2 = 0; - } + var_s0_2 = 0x00FF; + var_s1 = 0; + var_s2 = 0; } func_8004C024(0x0020, 0x0012, 0x0104, var_s0_2, var_s1, var_s2, 0x000000FF); func_8004C148(0x0124, 0x0012, 0x00CC, var_s0_2, var_s1, var_s2, 0x000000FF); func_8004C024(0x0020, 0x00DE, 0x0104, var_s0_2, var_s1, var_s2, 0x000000FF); func_8004C148(0x0020, 0x0012, 0x00CC, var_s0_2, var_s1, var_s2, 0x000000FF); } - if ((temp_v1 < 0) || (temp_v1 >= 3)) { + if ((lapCount < 0) || (lapCount >= MAX_LAPS)) { return; } - switch (temp_v1) { + switch (lapCount) { case 0: var_s0_2 = 0; var_s1 = 0; diff --git a/src/replays.c b/src/replays.c index ddd50faa15..afad5a9ec0 100644 --- a/src/replays.c +++ b/src/replays.c @@ -480,7 +480,7 @@ void func_80005AE8(Player* ply) { void func_80005B18(void) { if (gModeSelection == TIME_TRIALS) { - if ((gLapCountByPlayerId[0] == 3) && (D_80162DDC == 0) && (gPostTimeTrialReplayCannotSave != 1)) { + if ((gLapCountByPlayerId[0] == MAX_LAPS) && (D_80162DDC == 0) && (gPostTimeTrialReplayCannotSave != 1)) { if (bPlayerGhostDisabled == 1) { D_80162DD0 = D_80162DCC; func_800052A4(); @@ -492,7 +492,7 @@ void func_80005B18(void) { D_80162DFC = playerHUD[PLAYER_ONE].someTimer; func_80005AE8(gPlayerTwo); func_80005AE8(gPlayerThree); - } else if (gLapCountByPlayerId[1] != 3) { + } else if (gLapCountByPlayerId[1] != MAX_LAPS) { D_80162DD0 = D_80162DCC; func_800052A4(); D_80162DDC = 1; @@ -514,7 +514,7 @@ void func_80005B18(void) { func_80005AE8(gPlayerThree); } } else { - if ((gLapCountByPlayerId[0] == 3) && (D_80162DDC == 0) && (gPostTimeTrialReplayCannotSave == 1)) { + if ((gLapCountByPlayerId[0] == MAX_LAPS) && (D_80162DDC == 0) && (gPostTimeTrialReplayCannotSave == 1)) { sReplayGhostBuffer = D_802BFB80.arraySize8[0][D_80162DC8][3].pixel_index_array; sReplayGhostBufferSize = D_80162D86; D_80162DDC = 1; @@ -528,10 +528,10 @@ void func_80005B18(void) { sUnusedReplayCounter = 100; } if ((gModeSelection == TIME_TRIALS) && (gActiveScreenMode == SCREEN_MODE_1P)) { - if ((bPlayerGhostDisabled == 0) && (gLapCountByPlayerId[1] != 3)) { + if ((bPlayerGhostDisabled == 0) && (gLapCountByPlayerId[1] != MAX_LAPS)) { process_player_ghost_replay(); } - if ((bCourseGhostDisabled == 0) && (gLapCountByPlayerId[2] != 3)) { + if ((bCourseGhostDisabled == 0) && (gLapCountByPlayerId[2] != MAX_LAPS)) { process_course_ghost_replay(); } if (!(gPlayerOne->type & PLAYER_CINEMATIC_MODE)) { @@ -545,10 +545,10 @@ void func_80005B18(void) { void func_80005E6C(void) { if ((gModeSelection == TIME_TRIALS) && (gModeSelection == TIME_TRIALS) && (gActiveScreenMode == SCREEN_MODE_1P)) { - if ((D_80162DD8 == 0) && (gLapCountByPlayerId[1] != 3)) { + if ((D_80162DD8 == 0) && (gLapCountByPlayerId[1] != MAX_LAPS)) { process_player_ghost_replay(); // 3 } - if ((bCourseGhostDisabled == 0) && (gLapCountByPlayerId[2] != 3)) { + if ((bCourseGhostDisabled == 0) && (gLapCountByPlayerId[2] != MAX_LAPS)) { process_course_ghost_replay(); // 2 } if ((gPlayerOne->type & PLAYER_CINEMATIC_MODE) != PLAYER_CINEMATIC_MODE) {