Update readme.md
[openttd-joker.git] / src / script / api / script_depotlist.cpp
blob3e169b3da8881bc6ef3a59d91b11e6bca32d10f1
1 /* $Id: script_depotlist.cpp 23632 2011-12-19 21:05:25Z truebrain $ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
10 /** @file script_depotlist.cpp Implementation of ScriptDepotList and friends. */
12 #include "../../stdafx.h"
13 #include "script_depotlist.hpp"
14 #include "../../depot_base.h"
15 #include "../../station_base.h"
17 #include "../../safeguards.h"
19 ScriptDepotList::ScriptDepotList(ScriptTile::TransportType transport_type)
21 ::TileType tile_type;
22 switch (transport_type) {
23 default: return;
25 case ScriptTile::TRANSPORT_ROAD: tile_type = ::MP_ROAD; break;
26 case ScriptTile::TRANSPORT_RAIL: tile_type = ::MP_RAILWAY; break;
27 case ScriptTile::TRANSPORT_WATER: tile_type = ::MP_WATER; break;
29 case ScriptTile::TRANSPORT_AIR: {
30 /* Hangars are not seen as real depots by the depot code. */
31 const Station *st;
32 FOR_ALL_STATIONS(st) {
33 if (st->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) {
34 for (uint i = 0; i < st->airport.GetNumHangars(); i++) {
35 this->AddItem(st->airport.GetHangarTile(i));
39 return;
43 /* Handle 'standard' depots. */
44 const Depot *depot;
45 FOR_ALL_DEPOTS(depot) {
46 if ((::GetTileOwner(depot->xy) == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) && ::IsTileType(depot->xy, tile_type)) this->AddItem(depot->xy);