From 71b56c50f74203163ff9adc365e025df1e4dc6b2 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Thu, 15 Sep 2022 22:44:26 +0200 Subject: [PATCH] Use nearest_section in FindNearestGeneralSection --- src/DETHRACE/common/opponent.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/DETHRACE/common/opponent.c b/src/DETHRACE/common/opponent.c index 1f69520e..3772a2bf 100644 --- a/src/DETHRACE/common/opponent.c +++ b/src/DETHRACE/common/opponent.c @@ -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; @@ -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);