00001 /* $Id: script_depotlist.cpp 23632 2011-12-19 21:05:25Z truebrain $ */ 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 "../../depot_base.h" 00015 #include "../../station_base.h" 00016 00017 ScriptDepotList::ScriptDepotList(ScriptTile::TransportType transport_type) 00018 { 00019 ::TileType tile_type; 00020 switch (transport_type) { 00021 default: return; 00022 00023 case ScriptTile::TRANSPORT_ROAD: tile_type = ::MP_ROAD; break; 00024 case ScriptTile::TRANSPORT_RAIL: tile_type = ::MP_RAILWAY; break; 00025 case ScriptTile::TRANSPORT_WATER: tile_type = ::MP_WATER; break; 00026 00027 case ScriptTile::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 == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) { 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) == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) && ::IsTileType(depot->xy, tile_type)) this->AddItem(depot->xy); 00045 } 00046 }