Files
@ r20718:cc912091a170
Branch filter:
Location: cpp/openttd-patchpack/source/src/script/api/script_station.cpp - annotation
r20718:cc912091a170
5.2 KiB
text/x-c
(svn r25756) -Update from WebTranslator v3.0:
indonesian - 2 changes by UseYourIllusion
indonesian - 2 changes by UseYourIllusion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18774:2977cce7e239 r18500:14a481bc4437 r18500:14a481bc4437 r18766:e7b813549774 r18766:e7b813549774 r18766:e7b813549774 r18766:e7b813549774 r18766:e7b813549774 r18766:e7b813549774 r18766:e7b813549774 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r20188:c7660e0c9b5b r18500:14a481bc4437 r18500:14a481bc4437 r20172:3f30c8c6ef61 r20172:3f30c8c6ef61 r20172:3f30c8c6ef61 r20172:3f30c8c6ef61 r20172:3f30c8c6ef61 r20172:3f30c8c6ef61 r20172:3f30c8c6ef61 r20172:3f30c8c6ef61 r18501:8e3d905ea4bc r18500:14a481bc4437 r20172:3f30c8c6ef61 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18595:77f16a6b4e68 r18500:14a481bc4437 r18595:77f16a6b4e68 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18596:ff58faef3eff r18596:ff58faef3eff r18596:ff58faef3eff r18596:ff58faef3eff r18596:ff58faef3eff r18596:ff58faef3eff r18596:ff58faef3eff r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18501:8e3d905ea4bc r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r18500:14a481bc4437 r19224:da5678df5fbc r19224:da5678df5fbc r19224:da5678df5fbc r19224:da5678df5fbc r19224:da5678df5fbc r19224:da5678df5fbc r19224:da5678df5fbc r19224:da5678df5fbc r19224:da5678df5fbc r19224:da5678df5fbc r19224:da5678df5fbc r19224:da5678df5fbc r19224:da5678df5fbc r19224:da5678df5fbc r19224:da5678df5fbc r19224:da5678df5fbc | /* $Id$ */
/*
* 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/>.
*/
/** @file script_station.cpp Implementation of ScriptStation. */
#include "../../stdafx.h"
#include "script_station.hpp"
#include "script_map.hpp"
#include "script_town.hpp"
#include "../../station_base.h"
#include "../../roadstop_base.h"
#include "../../town.h"
/* static */ bool ScriptStation::IsValidStation(StationID station_id)
{
const Station *st = ::Station::GetIfValid(station_id);
return st != NULL && (st->owner == ScriptObject::GetCompany() || ScriptObject::GetCompany() == OWNER_DEITY || st->owner == OWNER_NONE);
}
/* static */ ScriptCompany::CompanyID ScriptStation::GetOwner(StationID station_id)
{
if (!IsValidStation(station_id)) return ScriptCompany::COMPANY_INVALID;
return static_cast<ScriptCompany::CompanyID>((int)::Station::Get(station_id)->owner);
}
/* static */ StationID ScriptStation::GetStationID(TileIndex tile)
{
if (!::IsValidTile(tile) || !::IsTileType(tile, MP_STATION)) return INVALID_STATION;
return ::GetStationIndex(tile);
}
/* static */ int32 ScriptStation::GetCargoWaiting(StationID station_id, CargoID cargo_id)
{
if (!IsValidStation(station_id)) return -1;
if (!ScriptCargo::IsValidCargo(cargo_id)) return -1;
return ::Station::Get(station_id)->goods[cargo_id].cargo.TotalCount();
}
/* static */ bool ScriptStation::HasCargoRating(StationID station_id, CargoID cargo_id)
{
if (!IsValidStation(station_id)) return false;
if (!ScriptCargo::IsValidCargo(cargo_id)) return false;
return ::Station::Get(station_id)->goods[cargo_id].HasRating();
}
/* static */ int32 ScriptStation::GetCargoRating(StationID station_id, CargoID cargo_id)
{
if (!ScriptStation::HasCargoRating(station_id, cargo_id)) return -1;
return ::ToPercent8(::Station::Get(station_id)->goods[cargo_id].rating);
}
/* static */ int32 ScriptStation::GetCoverageRadius(ScriptStation::StationType station_type)
{
if (station_type == STATION_AIRPORT) return -1;
if (!HasExactlyOneBit(station_type)) return -1;
if (!_settings_game.station.modified_catchment) return CA_UNMODIFIED;
switch (station_type) {
case STATION_TRAIN: return CA_TRAIN;
case STATION_TRUCK_STOP: return CA_TRUCK;
case STATION_BUS_STOP: return CA_BUS;
case STATION_DOCK: return CA_DOCK;
default: return CA_NONE;
}
}
/* static */ int32 ScriptStation::GetStationCoverageRadius(StationID station_id)
{
if (!IsValidStation(station_id)) return -1;
return Station::Get(station_id)->GetCatchmentRadius();
}
/* static */ int32 ScriptStation::GetDistanceManhattanToTile(StationID station_id, TileIndex tile)
{
if (!IsValidStation(station_id)) return -1;
return ScriptMap::DistanceManhattan(tile, GetLocation(station_id));
}
/* static */ int32 ScriptStation::GetDistanceSquareToTile(StationID station_id, TileIndex tile)
{
if (!IsValidStation(station_id)) return -1;
return ScriptMap::DistanceSquare(tile, GetLocation(station_id));
}
/* static */ bool ScriptStation::IsWithinTownInfluence(StationID station_id, TownID town_id)
{
if (!IsValidStation(station_id)) return false;
return ScriptTown::IsWithinTownInfluence(town_id, GetLocation(station_id));
}
/* static */ bool ScriptStation::HasStationType(StationID station_id, StationType station_type)
{
if (!IsValidStation(station_id)) return false;
if (!HasExactlyOneBit(station_type)) return false;
return (::Station::Get(station_id)->facilities & station_type) != 0;
}
/* static */ bool ScriptStation::HasRoadType(StationID station_id, ScriptRoad::RoadType road_type)
{
if (!IsValidStation(station_id)) return false;
if (!ScriptRoad::IsRoadTypeAvailable(road_type)) return false;
::RoadTypes r = RoadTypeToRoadTypes((::RoadType)road_type);
for (const RoadStop *rs = ::Station::Get(station_id)->GetPrimaryRoadStop(ROADSTOP_BUS); rs != NULL; rs = rs->next) {
if ((::GetRoadTypes(rs->xy) & r) != 0) return true;
}
for (const RoadStop *rs = ::Station::Get(station_id)->GetPrimaryRoadStop(ROADSTOP_TRUCK); rs != NULL; rs = rs->next) {
if ((::GetRoadTypes(rs->xy) & r) != 0) return true;
}
return false;
}
/* static */ TownID ScriptStation::GetNearestTown(StationID station_id)
{
if (!IsValidStation(station_id)) return INVALID_TOWN;
return ::Station::Get(station_id)->town->index;
}
/*static */ bool ScriptStation::IsAirportClosed(StationID station_id)
{
EnforcePrecondition(false, IsValidStation(station_id));
EnforcePrecondition(false, HasStationType(station_id, STATION_AIRPORT));
return (::Station::Get(station_id)->airport.flags & AIRPORT_CLOSED_block) != 0;
}
/*static */ bool ScriptStation::OpenCloseAirport(StationID station_id)
{
EnforcePrecondition(false, IsValidStation(station_id));
EnforcePrecondition(false, HasStationType(station_id, STATION_AIRPORT));
return ScriptObject::DoCommand(0, station_id, 0, CMD_OPEN_CLOSE_AIRPORT);
}
|