From 2c05412d722903748bf928fd201b15cdad586a94 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Tue, 31 Aug 2021 14:31:37 +0200 Subject: Fix #9407: desync when founding a town nearby a station (#9526) "stations_near" wasn't updated when founding a town near a station. As this variable is not saved, any client joining after the town is founded has a different value for "stations_near", potentially causing desyncs. As the intention of this if() statement was to skip an expensive calculation when there are clearly no stations, better to move that check inside the function, so other places also enjoy the speedup. --- src/station_base.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/station_base.h') diff --git a/src/station_base.h b/src/station_base.h index c63dcade1..eff191860 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -565,6 +565,9 @@ void RebuildStationKdtree(); template void ForAllStationsAroundTiles(const TileArea &ta, Func func) { + /* There are no stations, so we will never find anything. */ + if (Station::GetNumItems() == 0) return; + /* Not using, or don't have a nearby stations list, so we need to scan. */ std::set seen_stations; -- cgit v1.2.3-54-g00ecf