mirror of https://github.com/OpenTTD/OpenTTD
(svn r12133) -Fix: Vehicle sorting by max speed did not work properly for trains. Instead of trying to work it out again, just use the cached values...
parent
fd51465c8b
commit
b7cd791988
|
@ -644,22 +644,10 @@ static int CDECL VehicleMaxSpeedSorter(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
const Vehicle* va = *(const Vehicle**)a;
|
const Vehicle* va = *(const Vehicle**)a;
|
||||||
const Vehicle* vb = *(const Vehicle**)b;
|
const Vehicle* vb = *(const Vehicle**)b;
|
||||||
int max_speed_a = 0xFFFF, max_speed_b = 0xFFFF;
|
|
||||||
int r;
|
int r;
|
||||||
const Vehicle *ua = va, *ub = vb;
|
|
||||||
|
|
||||||
if (va->type == VEH_TRAIN && vb->type == VEH_TRAIN) {
|
if (va->type == VEH_TRAIN && vb->type == VEH_TRAIN) {
|
||||||
do {
|
r = va->u.rail.cached_max_speed - vb->u.rail.cached_max_speed;
|
||||||
if (RailVehInfo(ua->engine_type)->max_speed != 0)
|
|
||||||
max_speed_a = min(max_speed_a, RailVehInfo(ua->engine_type)->max_speed);
|
|
||||||
} while ((ua = ua->Next()) != NULL);
|
|
||||||
|
|
||||||
do {
|
|
||||||
if (RailVehInfo(ub->engine_type)->max_speed != 0)
|
|
||||||
max_speed_b = min(max_speed_b, RailVehInfo(ub->engine_type)->max_speed);
|
|
||||||
} while ((ub = ub->Next()) != NULL);
|
|
||||||
|
|
||||||
r = max_speed_a - max_speed_b;
|
|
||||||
} else {
|
} else {
|
||||||
r = va->max_speed - vb->max_speed;
|
r = va->max_speed - vb->max_speed;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue