Update: Translations from eints
[openttd-github.git] / src / script / api / script_depotlist.cpp
blobeb43139165d1ad765e5b17cbd15428de13136fd1
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file script_depotlist.cpp Implementation of ScriptDepotList and friends. */
10 #include "../../stdafx.h"
11 #include "script_depotlist.hpp"
12 #include "../../depot_base.h"
13 #include "../../station_base.h"
15 #include "../../safeguards.h"
17 ScriptDepotList::ScriptDepotList(ScriptTile::TransportType transport_type)
19 EnforceDeityOrCompanyModeValid_Void();
20 ::TileType tile_type;
21 switch (transport_type) {
22 default: return;
24 case ScriptTile::TRANSPORT_ROAD: tile_type = ::MP_ROAD; break;
25 case ScriptTile::TRANSPORT_RAIL: tile_type = ::MP_RAILWAY; break;
26 case ScriptTile::TRANSPORT_WATER: tile_type = ::MP_WATER; break;
28 case ScriptTile::TRANSPORT_AIR: {
29 /* Hangars are not seen as real depots by the depot code. */
30 bool is_deity = ScriptCompanyMode::IsDeity();
31 CompanyID owner = ScriptObject::GetCompany();
32 for (const Station *st : Station::Iterate()) {
33 if (is_deity || st->owner == owner) {
34 for (uint i = 0; i < st->airport.GetNumHangars(); i++) {
35 this->AddItem(st->airport.GetHangarTile(i).base());
39 return;
43 /* Handle 'standard' depots. */
44 bool is_deity = ScriptCompanyMode::IsDeity();
45 CompanyID owner = ScriptObject::GetCompany();
46 for (const Depot *depot : Depot::Iterate()) {
47 if ((is_deity || ::GetTileOwner(depot->xy) == owner) && ::IsTileType(depot->xy, tile_type)) this->AddItem(depot->xy.base());