# ai_depotlist.cpp

Go to the documentation of this file.

    00001 /* $Id: ai_depotlist.cpp 18860 2010-01-18 14:32:47Z 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           const AirportSpec *as = st->GetAirportSpec();
    00033           for (uint i = 0; i < as->nof_depots; i++) {
    00034             this->AddItem(st->GetHangarTile(i));
    00035           }
    00036         }
    00037       }
    00038       return;
    00039     }
    00040   }
    00041
    00042   /* Handle 'standard' depots. */
    00043   const Depot *depot;
    00044   FOR_ALL_DEPOTS(depot) {
    00045     if (::GetTileOwner(depot->xy) == ::_current_company && ::IsTileType(depot->xy, tile_type)) this->AddItem(depot->xy);
    00046   }
    00047 }