Skip to content

Commit

Permalink
Fix #9407: desync when founding a town nearby a station
Browse files Browse the repository at this point in the history
"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.
  • Loading branch information
TrueBrain committed Aug 31, 2021
1 parent 69e9acd commit 69515c5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/town_cmd.cpp
Expand Up @@ -2310,7 +2310,11 @@ static void MakeTownHouse(TileIndex t, Town *town, byte counter, byte stage, Hou
if (size & BUILDING_2_TILES_X) ClearMakeHouseTile(t + TileDiffXY(1, 0), town, counter, stage, ++type, random_bits);
if (size & BUILDING_HAS_4_TILES) ClearMakeHouseTile(t + TileDiffXY(1, 1), town, counter, stage, ++type, random_bits);

if (!_generating_world) {
/* Skip this somewhat expensive loop if we are on a map without any
* station. Read: a new map that is being generated.
* Note: we cannot use _generating_world, as it is also set when
* CmdFoundTown is used. */
if (_station_pool.items != 0) {
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;
Expand Down

0 comments on commit 69515c5

Please sign in to comment.