(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
authorbjarni
Sat, 02 Jun 2007 15:47:38 +0000
changeset 7283 3f3b3828b412
parent 7282 e8bb56823496
child 7284 4011594d249c
(svn r10025) -Fix: [build windows] sorting planes for capacity didn't check mail capacity. Now mail capacity is used if passenger capacity is the same
The sort will still resort to EngineID if both mail and passenger capacities are the same
src/build_vehicle_gui.cpp
--- a/src/build_vehicle_gui.cpp	Sat Jun 02 15:41:37 2007 +0000
+++ b/src/build_vehicle_gui.cpp	Sat Jun 02 15:47:38 2007 +0000
@@ -332,13 +332,20 @@
 
 static int CDECL AircraftEngineCargoSorter(const void *a, const void *b)
 {
-	const int va = AircraftVehInfo(*(const EngineID*)a)->passenger_capacity;
-	const int vb = AircraftVehInfo(*(const EngineID*)b)->passenger_capacity;
-	const int r = va - vb;
+	int va = AircraftVehInfo(*(const EngineID*)a)->passenger_capacity;
+	int vb = AircraftVehInfo(*(const EngineID*)b)->passenger_capacity;
+	int r = va - vb;
 
 	if (r == 0) {
-		/* Use EngineID to sort instead since we want consistent sorting */
-		return EngineNumberSorter(a, b);
+		/* The planes has the same passenger capacity. Check mail capacity instead */
+		va = AircraftVehInfo(*(const EngineID*)a)->mail_capacity;
+		vb = AircraftVehInfo(*(const EngineID*)b)->mail_capacity;
+		r = va - vb;
+
+		if (r == 0) {
+			/* Use EngineID to sort instead since we want consistent sorting */
+			return EngineNumberSorter(a, b);
+		}
 	}
 	return _internal_sort_order ? -r : r;
 }