00001 /* $Id$ */ 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 "../../stdafx.h" 00013 #include "script_depotlist.hpp" 00014 #include "../../company_func.h" 00015 #include "../../depot_base.h" 00016 #include "../../station_base.h" 00017 00018 ScriptDepotList::ScriptDepotList(ScriptTile::TransportType transport_type) 00019 { 00020 ::TileType tile_type; 00021 switch (transport_type) { 00022 default: return; 00023 00024 case ScriptTile::TRANSPORT_ROAD: tile_type = ::MP_ROAD; break; 00025 case ScriptTile::TRANSPORT_RAIL: tile_type = ::MP_RAILWAY; break; 00026 case ScriptTile::TRANSPORT_WATER: tile_type = ::MP_WATER; break; 00027 00028 case ScriptTile::TRANSPORT_AIR: { 00029 /* Hangars are not seen as real depots by the depot code. */ 00030 const Station *st; 00031 FOR_ALL_STATIONS(st) { 00032 if (st->owner == ::_current_company) { 00033 for (uint i = 0; i < st->airport.GetNumHangars(); i++) { 00034 this->AddItem(st->airport.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 }