# HG changeset patch # User truebrain # Date 1203956790 0 # Node ID a937441fecf177ce1636041810fc543fe190df7b # Parent bf67ecd8fd1f8c8e3a923c2b7a8bc992aee2b2bb (svn r12256) [NoAI] -Fix: because of a 'bug' in OpenTTD, FindStationsAroundIndustryTile gave inconsitant results with GetProductionAroundTiles (first ignores station layout). Fixed with HACK, waiting for real solution in OpenTTD. diff -r bf67ecd8fd1f -r a937441fecf1 bin/ai/regression/regression.txt --- a/bin/ai/regression/regression.txt Mon Feb 25 16:14:48 2008 +0000 +++ b/bin/ai/regression/regression.txt Mon Feb 25 16:26:30 2008 +0000 @@ -5298,9 +5298,8 @@ 19693 => 8 --TileList_IndustryProducing-- - Count(): 92 + Count(): 90 Location ListDump: - 46920 => 1 46919 => 1 46918 => 1 46917 => 1 @@ -5309,7 +5308,6 @@ 46914 => 1 46913 => 1 46912 => 1 - 46911 => 1 46664 => 1 46663 => 1 46662 => 1 diff -r bf67ecd8fd1f -r a937441fecf1 src/ai/api/ai_tilelist.cpp --- a/src/ai/api/ai_tilelist.cpp Mon Feb 25 16:14:48 2008 +0000 +++ b/src/ai/api/ai_tilelist.cpp Mon Feb 25 16:26:30 2008 +0000 @@ -130,6 +130,19 @@ if (!::IsValidTile(cur_tile)) continue; /* Exclude all tiles that belong to this industry */ if (::IsTileType(cur_tile, MP_INDUSTRY) && ::GetIndustryIndex(cur_tile) == industry_id) continue; + + /* Only add the tile if it produces the cargo (a bug in OpenTTD makes this + * inconsitance). */ + AcceptedCargo produces; + ::GetProductionAroundTiles(produces, cur_tile, 1, 1, radius); + { + bool cargo_produces = false; + for (byte j = 0; j < lengthof(indsp->produced_cargo); j++) { + if (indsp->produced_cargo[j] != CT_INVALID && produces[indsp->produced_cargo[j]] != 0) cargo_produces = true; + } + if (!cargo_produces) continue; + } + this->AddTile(cur_tile); } END_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius)) }