SpriteID TileZoneCheckAcceptionEvaluation(TileIndex tile, PlayerID player){ // It is silly to paint on an industry. if(IsTileType(tile, MP_INDUSTRY)) return INVALID_SPRITE_ID; CargoID cargo; bool all = false; ///< Only to be used if all cargo. cargo = (_zoning.inner == CHECKACCEPTGOODS) ? _zoning.inner_cargo : _zoning.outer_cargo; if(cargo==CT_INVALID) all = true; /* Most code in this function is from MoveGoodsToStation() */ static const int MAX_CATCHMENT = CA_DOCK; CargoID cargo_list[MAX_CATCHMENT]; memset(cargo_list, CT_INVALID, MAX_CATCHMENT); int w = 1; int h = 1; int w_prod; //width and height of the "producer" of the cargo int h_prod; int max_rad; if (_patches.modified_catchment) { w_prod = w; h_prod = h; w += 2*MAX_CATCHMENT; h += 2*MAX_CATCHMENT; max_rad = MAX_CATCHMENT; } else { w_prod = 0; h_prod = 0; w += 8; h += 8; max_rad = 4; } BEGIN_TILE_LOOP(cur_tile, w, h, tile - TileDiffXY(max_rad, max_rad)) cur_tile = TILE_MASK(cur_tile); if (!IsTileType(cur_tile, MP_INDUSTRY)) continue; const IndustrySpec *in = GetIndustrySpec(GetIndustryByTile(cur_tile)->type); // For now, only search the first cargo possible acceptance. if(in->accepts_cargo[0]==CT_INVALID) continue; if(!all && (in->accepts_cargo[0]==cargo)) return GetColourByCargoID(cargo); cargo_list[DistanceManhattan(tile, cur_tile)] = in->accepts_cargo[0]; END_TILE_LOOP(cur_tile, w, h, tile - TileDiffXY(max_rad, max_rad)) for(int i = 0; i<MAX_CATCHMENT; i++) if(cargo_list[i]!=CT_INVALID) return GetColourByCargoID(cargo_list[i]); return INVALID_SPRITE_ID;}