(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. noai
authortruebrain
Mon, 25 Feb 2008 16:26:30 +0000
branchnoai
changeset 9767 a937441fecf1
parent 9766 bf67ecd8fd1f
child 9768 28dfd4da5d62
(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.
bin/ai/regression/regression.txt
src/ai/api/ai_tilelist.cpp
--- 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
--- 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))
 }