From 223f11bb704c7ed205f7e4797ab2b7aca93dd367 Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 14 Feb 2015 22:48:28 +0000 Subject: [PATCH] Return count from insert_center_points --- similar/main/aipath.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/similar/main/aipath.cpp b/similar/main/aipath.cpp index 5f84e4584..5887f1aff 100644 --- a/similar/main/aipath.cpp +++ b/similar/main/aipath.cpp @@ -94,14 +94,13 @@ static void create_random_xlate(array &xt) // Insert the point at the center of the side connecting two segments between the two points. // This is messy because we must insert into the list. The simplest (and not too slow) way to do this is to start // at the end of the list and go backwards. -static void insert_center_points(point_seg *psegs, int *num_points) +static uint_fast32_t insert_center_points(point_seg *psegs, uint_fast32_t count) { - int i, last_point; - int count=*num_points; - - last_point = *num_points-1; - - for (i=last_point; i>0; i--) { + if (count < 2) + return count; + uint_fast32_t last_point = count - 1; + for (uint_fast32_t i = last_point; i; --i) + { psegs[2*i] = psegs[i]; auto connect_side = find_connect_side(&Segments[psegs[i].segnum], &Segments[psegs[i-1].segnum]); Assert(connect_side != -1); // Impossible! These two segments must be connected, they were created by create_path_points (which was created by mk!) @@ -125,13 +124,12 @@ static void insert_center_points(point_seg *psegs, int *num_points) count++; } -#if defined(DXX_BUILD_DESCENT_I) - *num_points = count; -#elif defined(DXX_BUILD_DESCENT_II) +#if defined(DXX_BUILD_DESCENT_II) // Now, remove unnecessary center points. // A center point is unnecessary if it is close to the line between the two adjacent points. // MK, OPTIMIZE! Can get away with about half the math since every vector gets computed twice. - for (i=1; i