src/ai/api/ai_tilelist.cpp
branchnoai
changeset 9765 4253d585cdbb
parent 9757 5cdc14959fb6
child 9766 bf67ecd8fd1f
equal deleted inserted replaced
9764:e499a1afc774 9765:4253d585cdbb
    75 
    75 
    76 	const Industry *i = ::GetIndustry(industry_id);
    76 	const Industry *i = ::GetIndustry(industry_id);
    77 	const IndustrySpec *indsp = ::GetIndustrySpec(i->type);
    77 	const IndustrySpec *indsp = ::GetIndustrySpec(i->type);
    78 
    78 
    79 	/* Check if this industry accepts anything */
    79 	/* Check if this industry accepts anything */
    80 	if (indsp->accepts_cargo[0] == CT_INVALID) return;
    80 	{
       
    81 		bool cargo_accepts = false;
       
    82 		for (byte j = 0; j < lengthof(indsp->accepts_cargo); j++) {
       
    83 			if (indsp->accepts_cargo[j] != CT_INVALID) cargo_accepts = true;
       
    84 		}
       
    85 		if (!cargo_accepts) return;
       
    86 	}
    81 
    87 
    82 	if (!_patches.modified_catchment) radius = CA_UNMODIFIED;
    88 	if (!_patches.modified_catchment) radius = CA_UNMODIFIED;
    83 
    89 
    84 	BEGIN_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius)) {
    90 	BEGIN_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius)) {
    85 		/* Exclude all tiles that belong to this industry */
    91 		/* Exclude all tiles that belong to this industry */
    87 
    93 
    88 		/* Only add the tile if it accepts the cargo (sometimes just 1 tile of an
    94 		/* Only add the tile if it accepts the cargo (sometimes just 1 tile of an
    89 		 *  industry triggers the acceptance). */
    95 		 *  industry triggers the acceptance). */
    90 		AcceptedCargo accepts;
    96 		AcceptedCargo accepts;
    91 		::GetAcceptanceAroundTiles(accepts, cur_tile, 1, 1, radius);
    97 		::GetAcceptanceAroundTiles(accepts, cur_tile, 1, 1, radius);
    92 		if (accepts[indsp->accepts_cargo[0]] == 0) continue;
    98 		{
       
    99 			bool cargo_accepts = false;
       
   100 			for (byte j = 0; j < lengthof(indsp->accepts_cargo); j++) {
       
   101 				if (indsp->accepts_cargo[j] != CT_INVALID && accepts[indsp->accepts_cargo[j]] != 0) cargo_accepts = true;
       
   102 			}
       
   103 			if (!cargo_accepts) continue;
       
   104 		}
    93 
   105 
    94 		this->AddTile(cur_tile);
   106 		this->AddTile(cur_tile);
    95 	} END_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius))
   107 	} END_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius))
    96 }
   108 }
    97 
   109 
   101 
   113 
   102 	const Industry *i = ::GetIndustry(industry_id);
   114 	const Industry *i = ::GetIndustry(industry_id);
   103 	const IndustrySpec *indsp = ::GetIndustrySpec(i->type);
   115 	const IndustrySpec *indsp = ::GetIndustrySpec(i->type);
   104 
   116 
   105 	/* Check if this industry produces anything */
   117 	/* Check if this industry produces anything */
   106 	if (indsp->produced_cargo[0] == CT_INVALID) return;
   118 	{
       
   119 		bool cargo_produces = false;
       
   120 		for (byte j = 0; j < lengthof(indsp->produced_cargo); j++) {
       
   121 			if (indsp->produced_cargo[j] != CT_INVALID) cargo_produces = true;
       
   122 		}
       
   123 		if (!cargo_produces) return;
       
   124 	}
   107 
   125 
   108 	if (!_patches.modified_catchment) radius = CA_UNMODIFIED;
   126 	if (!_patches.modified_catchment) radius = CA_UNMODIFIED;
   109 
   127 
   110 	BEGIN_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius)) {
   128 	BEGIN_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius)) {
   111 		/* Exclude all tiles that belong to this industry */
   129 		/* Exclude all tiles that belong to this industry */