2009-01-12 17:11:45 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
/** @file script_depotlist.cpp Implementation of ScriptDepotList and friends. */
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-01-22 10:33:16 +00:00
|
|
|
#include "../../stdafx.h"
|
2011-11-29 23:07:38 +00:00
|
|
|
#include "script_depotlist.hpp"
|
2009-01-12 17:11:45 +00:00
|
|
|
#include "../../depot_base.h"
|
|
|
|
#include "../../station_base.h"
|
|
|
|
|
2014-04-23 20:13:33 +00:00
|
|
|
#include "../../safeguards.h"
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
ScriptDepotList::ScriptDepotList(ScriptTile::TransportType transport_type)
|
2009-01-12 17:11:45 +00:00
|
|
|
{
|
|
|
|
::TileType tile_type;
|
|
|
|
switch (transport_type) {
|
|
|
|
default: return;
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
case ScriptTile::TRANSPORT_ROAD: tile_type = ::MP_ROAD; break;
|
|
|
|
case ScriptTile::TRANSPORT_RAIL: tile_type = ::MP_RAILWAY; break;
|
|
|
|
case ScriptTile::TRANSPORT_WATER: tile_type = ::MP_WATER; break;
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
case ScriptTile::TRANSPORT_AIR: {
|
2009-01-12 17:11:45 +00:00
|
|
|
/* Hangars are not seen as real depots by the depot code. */
|
|
|
|
const Station *st;
|
|
|
|
FOR_ALL_STATIONS(st) {
|
2011-12-19 21:05:25 +00:00
|
|
|
if (st->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) {
|
2010-03-19 11:17:52 +00:00
|
|
|
for (uint i = 0; i < st->airport.GetNumHangars(); i++) {
|
2010-03-19 09:58:46 +00:00
|
|
|
this->AddItem(st->airport.GetHangarTile(i));
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle 'standard' depots. */
|
|
|
|
const Depot *depot;
|
|
|
|
FOR_ALL_DEPOTS(depot) {
|
2011-12-19 21:05:25 +00:00
|
|
|
if ((::GetTileOwner(depot->xy) == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY) && ::IsTileType(depot->xy, tile_type)) this->AddItem(depot->xy);
|
2009-01-12 17:11:45 +00:00
|
|
|
}
|
|
|
|
}
|