From c1d79398d57b4b8a013fcca62e72a5ce9efc137f Mon Sep 17 00:00:00 2001 From: dP Date: Sat, 31 Jul 2021 22:46:36 +0300 Subject: Fix: Use of unstable sort when distributing cargo production can cause desyncs --- src/station_cmd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index a58c7b1f2..6a5cabc8d 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -4080,7 +4080,7 @@ uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, Sourc /* If there is some cargo left due to rounding issues distribute it among the best rated stations. */ if (amount > moving) { - std::sort(used_stations.begin(), used_stations.end(), [type](const StationInfo &a, const StationInfo &b) { + std::stable_sort(used_stations.begin(), used_stations.end(), [type](const StationInfo &a, const StationInfo &b) { return b.first->goods[type].rating < a.first->goods[type].rating; }); -- cgit v1.2.3-70-g09d2