MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ScriptDepotList

Method ScriptDepotList

src/script/api/script_depotlist.cpp:17–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include "../../safeguards.h"
16
17ScriptDepotList::ScriptDepotList(ScriptTile::TransportType transport_type)
18{
19 EnforceDeityOrCompanyModeValid_Void();
20 ::TileType tile_type;
21 switch (transport_type) {
22 default: return;
23
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;
27
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());
36 }
37 }
38 }
39 return;
40 }
41 }
42
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());
48 }
49}

Callers

nothing calls this directly

Calls 6

GetTileOwnerFunction · 0.85
IsTileTypeFunction · 0.85
AddItemMethod · 0.80
GetHangarTileMethod · 0.80
GetNumHangarsMethod · 0.45
baseMethod · 0.45

Tested by

no test coverage detected