00001 /* $Id: ai_depotlist.cpp 19465 2010-03-19 11:17:52Z yexo $ */ 00002 00003 /* 00004 * This file is part of OpenTTD. 00005 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. 00006 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00007 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. 00008 */ 00009 00012 #include "ai_depotlist.hpp" 00013 #include "../../company_func.h" 00014 #include "../../depot_base.h" 00015 #include "../../station_base.h" 00016 00017 AIDepotList::AIDepotList(AITile::TransportType transport_type) 00018 { 00019 ::TileType tile_type; 00020 switch (transport_type) { 00021 default: return; 00022 00023 case AITile::TRANSPORT_ROAD: tile_type = ::MP_ROAD; break; 00024 case AITile::TRANSPORT_RAIL: tile_type = ::MP_RAILWAY; break; 00025 case AITile::TRANSPORT_WATER: tile_type = ::MP_WATER; break; 00026 00027 case AITile::TRANSPORT_AIR: { 00028 /* Hangars are not seen as real depots by the depot code. */ 00029 const Station *st; 00030 FOR_ALL_STATIONS(st) { 00031 if (st->owner == ::_current_company) { 00032 for (uint i = 0; i < st->airport.GetNumHangars(); i++) { 00033 this->AddItem(st->airport.GetHangarTile(i)); 00034 } 00035 } 00036 } 00037 return; 00038 } 00039 } 00040 00041 /* Handle 'standard' depots. */ 00042 const Depot *depot; 00043 FOR_ALL_DEPOTS(depot) { 00044 if (::GetTileOwner(depot->xy) == ::_current_company && ::IsTileType(depot->xy, tile_type)) this->AddItem(depot->xy); 00045 } 00046 }