Skip to content

Commit

Permalink
Use nearest_section in FindNearestGeneralSection (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr committed Sep 16, 2022
1 parent 25ecaf7 commit 4c6e3a3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/DETHRACE/common/opponent.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ tS16 FindNearestGeneralSection(tCar_spec* pPursuee, br_vector3* pActor_coords, b
closest_distance_squared = BR_SCALAR_MAX;
nearest_node_distance_squared = BR_SCALAR_MAX;

if (pPursuee) {
if (pPursuee != NULL) {
no_sections = pPursuee->my_trail.number_of_nodes - 1;
} else {
no_sections = gProgram_state.AI_vehicles.number_of_path_sections;
Expand Down Expand Up @@ -297,11 +297,11 @@ tS16 FindNearestGeneralSection(tCar_spec* pPursuee, br_vector3* pActor_coords, b
if (nearest_node_distance_squared > closest_distance_squared) {
nearest_node_section_no = nearest_section;
if (pPursuee != NULL) {
start = &pPursuee->my_trail.trail_nodes[section_no];
finish = &pPursuee->my_trail.trail_nodes[section_no + 1];
start = &pPursuee->my_trail.trail_nodes[nearest_section];
finish = &pPursuee->my_trail.trail_nodes[nearest_section + 1];
} else {
start = &gProgram_state.AI_vehicles.path_nodes[gProgram_state.AI_vehicles.path_sections[section_no].node_indices[0]].p;
finish = &gProgram_state.AI_vehicles.path_nodes[gProgram_state.AI_vehicles.path_sections[section_no].node_indices[1]].p;
start = &gProgram_state.AI_vehicles.path_nodes[gProgram_state.AI_vehicles.path_sections[nearest_section].node_indices[0]].p;
finish = &gProgram_state.AI_vehicles.path_nodes[gProgram_state.AI_vehicles.path_sections[nearest_section].node_indices[1]].p;
}
BrVector3Sub(&p, finish, start);
BrVector3NormaliseQuick(pPath_direction, &p);
Expand Down

0 comments on commit 4c6e3a3

Please sign in to comment.