(svn r244) -Fix: Stations were not sorted for non-player-0 players

-Fix: Correctly resorting vehicle list of player when the list of another player is open.
This commit is contained in:
darkvater
2004-09-14 14:19:53 +00:00
parent 5e699ca65d
commit c79e8ad626
8 changed files with 215 additions and 167 deletions

View File

@@ -6,23 +6,11 @@
/* General Vehicle GUI based procedures that are independent of vehicle types */
void InitializeVehiclesGuiList()
{
bool *i;
for (i = _train_sort_dirty; i != endof(_train_sort_dirty); i++)
*i = true;
for (i = _aircraft_sort_dirty; i != endof(_aircraft_sort_dirty); i++)
*i = true;
for (i = _ship_sort_dirty; i != endof(_ship_sort_dirty); i++)
*i = true;
for (i = _road_sort_dirty; i != endof(_road_sort_dirty); i++)
*i = true;
for (i = _vehicle_sort_dirty; i != endof(_vehicle_sort_dirty); i++)
*i = true;
//memset(_train_sort_dirty, true, sizeof(_train_sort_dirty));
memset(_train_sort_dirty, true, sizeof(_train_sort_dirty));
memset(_aircraft_sort_dirty, true, sizeof(_aircraft_sort_dirty));
memset(_ship_sort_dirty, true, sizeof(_ship_sort_dirty));
memset(_road_sort_dirty, true, sizeof(_road_sort_dirty));
memset(_vehicle_sort_dirty, true, sizeof(_vehicle_sort_dirty));
}
// draw the vehicle profit button in the vehicle list window.
@@ -59,15 +47,15 @@ int CDECL VehicleUnsortedSorter(const void *a, const void *b)
return DEREF_VEHICLE((*(const SortStruct*)a).index)->index - DEREF_VEHICLE((*(const SortStruct*)b).index)->index;
}
// if the sorting criteria had the same value, sort vehicle by unitnumber
#define VEHICLEUNITNUMBERSORTER(r, a, b) {if (r == 0) {r = a->unitnumber - b->unitnumber;}}
int CDECL VehicleNumberSorter(const void *a, const void *b)
{
const Vehicle *va = DEREF_VEHICLE((*(const SortStruct*)a).index);
const Vehicle *vb = DEREF_VEHICLE((*(const SortStruct*)b).index);
int r = va->unitnumber - vb->unitnumber;
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
r = va->unitnumber - vb->unitnumber;
return (_internal_sort_order & 1) ? -r : r;
}
@@ -97,8 +85,7 @@ int CDECL VehicleNameSorter(const void *a, const void *b)
r = strcmp(buf1, _bufcache); // sort by name
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
r = va->unitnumber - vb->unitnumber;
VEHICLEUNITNUMBERSORTER(r, va, vb);
return (_internal_sort_order & 1) ? -r : r;
}
@@ -109,8 +96,7 @@ int CDECL VehicleAgeSorter(const void *a, const void *b)
const Vehicle *vb = DEREF_VEHICLE((*(const SortStruct*)b).index);
int r = va->age - vb->age;
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
r = va->unitnumber - vb->unitnumber;
VEHICLEUNITNUMBERSORTER(r, va, vb);
return (_internal_sort_order & 1) ? -r : r;
}
@@ -121,8 +107,7 @@ int CDECL VehicleProfitThisYearSorter(const void *a, const void *b)
const Vehicle *vb = DEREF_VEHICLE((*(const SortStruct*)b).index);
int r = va->profit_this_year - vb->profit_this_year;
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
r = va->unitnumber - vb->unitnumber;
VEHICLEUNITNUMBERSORTER(r, va, vb);
return (_internal_sort_order & 1) ? -r : r;
}
@@ -133,8 +118,7 @@ int CDECL VehicleProfitLastYearSorter(const void *a, const void *b)
const Vehicle *vb = DEREF_VEHICLE((*(const SortStruct*)b).index);
int r = va->profit_last_year - vb->profit_last_year;
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
r = va->unitnumber - vb->unitnumber;
VEHICLEUNITNUMBERSORTER(r, va, vb);
return (_internal_sort_order & 1) ? -r : r;
}
@@ -175,8 +159,7 @@ int CDECL VehicleReliabilitySorter(const void *a, const void *b)
const Vehicle *vb = DEREF_VEHICLE((*(const SortStruct*)b).index);
int r = va->reliability - vb->reliability;
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
r = va->unitnumber - vb->unitnumber;
VEHICLEUNITNUMBERSORTER(r, va, vb);
return (_internal_sort_order & 1) ? -r : r;
}
@@ -187,8 +170,7 @@ int CDECL VehicleMaxSpeedSorter(const void *a, const void *b)
const Vehicle *vb = DEREF_VEHICLE((*(const SortStruct*)b).index);
int r = va->max_speed - vb->max_speed;
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
r = va->unitnumber - vb->unitnumber;
VEHICLEUNITNUMBERSORTER(r, va, vb);
return (_internal_sort_order & 1) ? -r : r;
}