Merge branch 'master' into jgrpp

# Conflicts:
#	src/core/alloc_type.hpp
#	src/group_gui.cpp
#	src/newgrf.cpp
#	src/saveload/economy_sl.cpp
#	src/saveload/map_sl.cpp
#	src/station_cmd.cpp
This commit is contained in:
Jonathan G Rennison
2019-04-16 18:03:08 +01:00
57 changed files with 524 additions and 635 deletions

View File

@@ -342,15 +342,12 @@ CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1,
* Order vehicles based on their timetable. The vehicles will be sorted in order
* they would reach the first station.
*
* @param ap First Vehicle pointer.
* @param bp Second Vehicle pointer.
* @param a First Vehicle pointer.
* @param b Second Vehicle pointer.
* @return Comparison value.
*/
static int CDECL VehicleTimetableSorter(Vehicle * const *ap, Vehicle * const *bp)
static bool VehicleTimetableSorter(Vehicle * const &a, Vehicle * const &b)
{
const Vehicle *a = *ap;
const Vehicle *b = *bp;
VehicleOrderID a_order = a->cur_real_order_index;
VehicleOrderID b_order = b->cur_real_order_index;
int j = (int)b_order - (int)a_order;
@@ -368,15 +365,15 @@ static int CDECL VehicleTimetableSorter(Vehicle * const *ap, Vehicle * const *bp
/* First check the order index that accounted for loading, then just the raw one. */
int i = (int)b_order - (int)a_order;
if (i != 0) return i;
if (j != 0) return j;
if (i != 0) return i < 0;
if (j != 0) return j < 0;
/* Look at the time we spent in this order; the higher, the closer to its destination. */
i = b->current_order_time - a->current_order_time;
if (i != 0) return i;
if (i != 0) return i < 0;
/* If all else is equal, use some unique index to sort it the same way. */
return b->unitnumber - a->unitnumber;
return b->unitnumber < a->unitnumber;
}
/**
@@ -421,7 +418,7 @@ CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1,
int num_vehs = (uint)vehs.size();
if (num_vehs >= 2) {
QSortT(vehs.data(), vehs.size(), &VehicleTimetableSorter);
std::sort(vehs.begin(), vehs.end(), &VehicleTimetableSorter);
}
int idx = vehs.begin() - std::find(vehs.begin(), vehs.end(), v);