Fix: Use of unstable sort when distributing cargo production can cause desyncs

(cherry picked from commit 4ed694fe98b146d984826d06b96e0c11045239bc)

See: https://github.com/OpenTTD/OpenTTD/pull/9460
This commit is contained in:
dP
2021-07-31 22:46:36 +03:00
committed by Jonathan G Rennison
parent 9003ef7d11
commit 9176fe5f64

View File

@@ -4584,7 +4584,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;
});