Changeset - r24194:3fe78c0da8f8
[Not reviewed]
master
0 4 0
dP - 5 years ago 2020-05-11 23:21:14
dp@dpointer.org
Fix #8137: New clients can't join (desync) after funding an industry
4 files changed with 12 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -1697,9 +1697,11 @@ static void PopulateStationsNearby(Indus
 
		return;
 
	}
 

	
 
	ForAllStationsAroundTiles(ind->location, [ind](Station *st) {
 
	ForAllStationsAroundTiles(ind->location, [ind](Station *st, TileIndex tile) {
 
		if (!IsTileType(tile, MP_INDUSTRY) || GetIndustryIndex(tile) != ind->index) return false;
 
		ind->stations_near.insert(st);
 
		st->AddIndustryToDeliver(ind);
 
		return true;
 
	});
 
}
 

	
src/station_base.h
Show inline comments
 
@@ -560,7 +560,10 @@ void RebuildStationKdtree();
 

	
 
/**
 
 * Call a function on all stations that have any part of the requested area within their catchment.
 
 * @param area The tile area to check
 
 * @tparam Func The type of funcion to call
 
 * @param area The TileArea to check
 
 * @param func The function to call, must take two parameters: Station* and TileIndex and return true
 
 *             if coverage of that tile is acceptable for a given station or false if search should continue
 
 */
 
template<typename Func>
 
void ForAllStationsAroundTiles(const TileArea &ta, Func func)
 
@@ -586,8 +589,7 @@ void ForAllStationsAroundTiles(const Til
 
		/* Test if the tile is within the station's catchment */
 
		TILE_AREA_LOOP(tile, ta) {
 
			if (st->TileIsInCatchment(tile)) {
 
				func(st);
 
				break;
 
				if (func(st, tile)) break;
 
			}
 
		}
 
	}
src/station_cmd.cpp
Show inline comments
 
@@ -3978,8 +3978,9 @@ const StationList *StationFinder::GetSta
 
			assert(this->w == 1 && this->h == 1);
 
			AddNearbyStationsByCatchment(this->tile, &this->stations, Town::GetByTile(this->tile)->stations_near);
 
		} else {
 
			ForAllStationsAroundTiles(*this, [this](Station *st) {
 
			ForAllStationsAroundTiles(*this, [this](Station *st, TileIndex tile) {
 
				this->stations.insert(st);
 
				return true;
 
			});
 
		}
 
		this->tile = INVALID_TILE;
src/town_cmd.cpp
Show inline comments
 
@@ -2250,8 +2250,9 @@ static void MakeTownHouse(TileIndex t, T
 
	if (size & BUILDING_HAS_4_TILES) ClearMakeHouseTile(t + TileDiffXY(1, 1), town, counter, stage, ++type, random_bits);
 

	
 
	if (!_generating_world) {
 
		ForAllStationsAroundTiles(TileArea(t, (size & BUILDING_2_TILES_X) ? 2 : 1, (size & BUILDING_2_TILES_Y) ? 2 : 1), [town](Station *st) {
 
		ForAllStationsAroundTiles(TileArea(t, (size & BUILDING_2_TILES_X) ? 2 : 1, (size & BUILDING_2_TILES_Y) ? 2 : 1), [town](Station *st, TileIndex tile) {
 
			town->stations_near.insert(st);
 
			return true;
 
		});
 
	}
 
}
0 comments (0 inline, 0 general)