Skip to content

Commit

Permalink
some rename
Browse files Browse the repository at this point in the history
  • Loading branch information
coco875 committed Jan 5, 2025
1 parent 6e6c25a commit a2f904c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ glabel update_player_path_completion
/* 00A340 80009740 304C1000 */ andi $t4, $v0, 0x1000
/* 00A344 80009744 1580001E */ bnez $t4, .L800097C0
/* 00A348 80009748 01402825 */ move $a1, $t2
/* 00A34C 8000974C 0C001974 */ jal detect_player_wrong_direction
/* 00A34C 8000974C 0C001974 */ jal detect_wrong_player_direction
/* 00A350 80009750 AFA40050 */ sw $a0, 0x50($sp)
/* 00A354 80009754 3C0D800E */ lui $t5, %hi(gModeSelection)
/* 00A358 80009758 8DADC53C */ lw $t5, %lo(gModeSelection)($t5)
Expand Down
2 changes: 1 addition & 1 deletion include/waypoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ extern s16 gCpuNeedChoosePath[];
// Is 1 when a player leaves the "unknown" zone in yoshi's valley
extern s16 gCpuResetPath[];
// Tracks whether a given player is in the "unknown" zone of yoshi's valley
extern s16 gNeedToChoose[];
extern s16 gNeedToChoosePath[];

#endif
33 changes: 18 additions & 15 deletions src/cpu_logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ TrackWaypoint* gCurrentTrackPath;
f32 D_80164498[4];
f32 gLapCompletionPercentByPlayerId[10]; // D_801644A8
f32 gCourseCompletionPercentByPlayerId[10]; // D_801644D0
s16 gNeedToChoose[12];
s16 gNeedToChoosePath[12];
f32 gPlayerPathY[10];
s16 D_80164538[12];
TrackWaypoint* gTrackPath[4];
Expand Down Expand Up @@ -670,7 +670,7 @@ s32 set_vehicle_render_distance_flags(Vec3f vehiclePos, f32 renderDistance, s32
return flag;
}

void detect_player_wrong_direction(s32 playerId, Player* player) {
void detect_wrong_player_direction(s32 playerId, Player* player) {
s16 playerAngle;
s16 rotationDifference;
s16 waypointAngle;
Expand Down Expand Up @@ -797,7 +797,7 @@ void set_places(void) {
}
}

void update_places(void) {
void update_player_rankings(void) {
f32 temp_f0;
UNUSED s32 pad;
s32 playerIds[8];
Expand Down Expand Up @@ -921,8 +921,8 @@ void set_places_end_course_with_time(void) {
*
* @param waypoint The waypoint to check
* @param currentWaypoint The reference waypoint
* @param backwardRange Number of waypoints to check behind
* @param forwardRange Number of waypoints to check ahead
* @param backwardRange Number of waypoints to look behind
* @param forwardRange Number of waypoints to look ahead
* @param totalWaypoints Total number of waypoints in the track
* @return
* 1: waypoint is within normal range
Expand Down Expand Up @@ -1356,7 +1356,10 @@ s32 update_player_path_selection(s32 payerId, s32 pathIndex) {
void update_player_completion(s32 playerId) {
f32 percent;

// arbitrary score calculation
gLapProgressScore[playerId] = (gLapCountByPlayerId[playerId] * gPathCountByPathIndex[0]) + sSomeNearestWaypoint;

// calculate completion in percent
percent = (f32) gNearestWaypointByPlayerId[playerId] / (f32) gPathCountByPathIndex[gPathIndexByPlayerId[playerId]];
gLapCompletionPercentByPlayerId[playerId] = percent;
gCourseCompletionPercentByPlayerId[playerId] = percent;
Expand All @@ -1366,36 +1369,36 @@ void update_player_completion(s32 playerId) {
void yoshi_valley_cpu_path(s32 playerId) {
s16 previous;

previous = gNeedToChoose[playerId];
previous = gNeedToChoosePath[playerId];
if (sSomeNearestWaypoint >= 0x6D) {
gNeedToChoose[playerId] = true;
gNeedToChoosePath[playerId] = true;
switch (gActualPath) {
case 0:
if (sSomeNearestWaypoint >= 0x20F) {
gNeedToChoose[playerId] = false;
gNeedToChoosePath[playerId] = false;
}
break;
case 1:
if (sSomeNearestWaypoint >= 0x206) {
gNeedToChoose[playerId] = false;
gNeedToChoosePath[playerId] = false;
}
break;
case 2:
if (sSomeNearestWaypoint >= 0x211) {
gNeedToChoose[playerId] = false;
gNeedToChoosePath[playerId] = false;
}
break;
case 3:
if (sSomeNearestWaypoint >= 0x283) {
gNeedToChoose[playerId] = false;
gNeedToChoosePath[playerId] = false;
}
break;
}
}
if ((previous == false) && (gNeedToChoose[playerId] == true)) {
if ((previous == false) && (gNeedToChoosePath[playerId] == true)) {
gCpuNeedChoosePath[playerId] = true;
}
if ((previous == true) && (gNeedToChoose[playerId] == false)) {
if ((previous == true) && (gNeedToChoosePath[playerId] == false)) {
gCpuResetPath[playerId] = true;
}
}
Expand Down Expand Up @@ -1529,7 +1532,7 @@ void update_player_path_completion(s32 playerId, Player* player) {
}
}
if ((player->type & PLAYER_HUMAN) && !(player->type & PLAYER_KART_AI)) {
detect_player_wrong_direction(playerId, player);
detect_wrong_player_direction(playerId, player);
if ((gModeSelection == 0) && (gPlayerCount == 2) && (playerId == 0)) {
if (gGPCurrentRaceRankByPlayerIdDup[PLAYER_ONE] < gGPCurrentRaceRankByPlayerIdDup[PLAYER_TWO]) {
gPlayerInFront = PLAYER_ONE;
Expand Down Expand Up @@ -3655,7 +3658,7 @@ void init_players(void) {
var_s5->step = 0.015f;
reset_kart_ai_behaviour_none(i);
gSpeedKartAIBehaviour[i] = 0;
gNeedToChoose[i] = 0;
gNeedToChoosePath[i] = 0;
D_80163398[i] = 0;
D_801633B0[i] = 0;
gPositionSwapTimer[i] = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/cpu_logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ s16 get_angle_between_waypoints(Vec3f, Vec3f);
s32 is_collide_with_vehicle(f32, f32, f32, f32, f32, f32, f32, f32);
void adjust_position_by_angle(Vec3f, Vec3f, s16);
s32 set_vehicle_render_distance_flags(Vec3f, f32, s32);
void detect_player_wrong_direction(s32, Player*);
void detect_wrong_player_direction(s32, Player*);
void set_places(void);

void update_places(void);
void update_player_rankings(void);
void set_places_end_course_with_time(void);
s32 is_path_point_in_range(u16, u16, u16, u16, u16);
void func_80007D04(s32, Player*);
Expand Down Expand Up @@ -411,7 +411,7 @@ extern s32 D_8016448C;
extern f32 D_80164498[];
extern f32 gLapCompletionPercentByPlayerId[]; // D_801644A8
extern f32 gCourseCompletionPercentByPlayerId[]; // D_801644D0
extern s16 gNeedToChoose[];
extern s16 gNeedToChoosePath[];
extern f32 gPlayerPathY[];
extern s16 D_80164538[];
extern s32 D_801645D0[];
Expand Down
2 changes: 1 addition & 1 deletion src/racing/race_logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void func_8028E298(void) {
gTimePlayerLastTouchedFinishLine[i] = gCourseTimer + temp_v0;
}
D_8016348C = 1;
update_places();
update_player_rankings();
}

void func_8028E3A0(void) {
Expand Down

0 comments on commit a2f904c

Please sign in to comment.