00001 /* $Id: ai_depotlist.cpp 16741 2009-07-04 17:20:48Z rubidium $ */ 00002 00005 #include "ai_depotlist.hpp" 00006 #include "../../tile_map.h" 00007 #include "../../company_func.h" 00008 #include "../../depot_base.h" 00009 #include "../../station_base.h" 00010 00011 AIDepotList::AIDepotList(AITile::TransportType transport_type) 00012 { 00013 ::TileType tile_type; 00014 switch (transport_type) { 00015 default: return; 00016 00017 case AITile::TRANSPORT_ROAD: tile_type = ::MP_ROAD; break; 00018 case AITile::TRANSPORT_RAIL: tile_type = ::MP_RAILWAY; break; 00019 case AITile::TRANSPORT_WATER: tile_type = ::MP_WATER; break; 00020 00021 case AITile::TRANSPORT_AIR: { 00022 /* Hangars are not seen as real depots by the depot code. */ 00023 const Station *st; 00024 FOR_ALL_STATIONS(st) { 00025 if (st->owner == ::_current_company) { 00026 const AirportFTAClass *afc = st->Airport(); 00027 for (uint i = 0; i < afc->nof_depots; i++) { 00028 this->AddItem(st->airport_tile + ToTileIndexDiff(afc->airport_depots[i])); 00029 } 00030 } 00031 } 00032 return; 00033 } 00034 } 00035 00036 /* Handle 'standard' depots. */ 00037 const Depot *depot; 00038 FOR_ALL_DEPOTS(depot) { 00039 if (::GetTileOwner(depot->xy) == ::_current_company && ::IsTileType(depot->xy, tile_type)) this->AddItem(depot->xy); 00040 } 00041 }