- fix insertion sort implementation in gamesnd

This commit is contained in:
Ilya Shurumov 2022-04-03 18:26:40 +06:00
parent 0a3574bc5c
commit ecf5b527e6

View File

@ -1005,20 +1005,19 @@ void DoDopplerSFX(void)
}
}
// sort cars by distance distance
for (i = 0; i < num_noisy_cars - 1; i++)
{
for (j = i + 1; j < num_noisy_cars; j++)
// sort cars by distance
for (i = 1; i < num_noisy_cars; i++)
{
int tmpi;
tmpi = indexlist[i];
if (car_dist[indexlist[j]] < car_dist[tmpi])
j = i - 1;
while (j >= 0 && car_dist[indexlist[j]] > car_dist[tmpi])
{
indexlist[i] = indexlist[j];
indexlist[j] = tmpi;
}
indexlist[j + 1] = indexlist[j];
j = j - 1;
}
indexlist[j + 1] = tmpi;
}
car_flags = 0;