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 */ 7 8 /** @file script_stationlist.hpp List all the stations (you own). */ 9 10 #ifndef SCRIPT_STATIONLIST_HPP 11 #define SCRIPT_STATIONLIST_HPP 12 13 #include "script_list.hpp" 14 #include "script_station.hpp" 15 16 /** 17 * Creates a list of stations of which you are the owner. 18 * @api ai game 19 * @ingroup ScriptList 20 */ 21 class ScriptStationList : public ScriptList { 22 public: 23 /** 24 * @param station_type The type of station to make a list of stations for. 25 */ 26 ScriptStationList(ScriptStation::StationType station_type); 27 }; 28 29 /** 30 * Creates a list of stations associated with cargo at a station. This is very generic. Use the 31 * subclasses for all practical purposes. 32 * @api ai game 33 * @ingroup ScriptList 34 */ 35 class ScriptStationList_Cargo : public ScriptList { 36 public: 37 /** 38 * Criteria of selecting and grouping cargo at a station. 39 */ 40 enum CargoSelector { 41 CS_BY_FROM, ///< Group by origin station. 42 CS_VIA_BY_FROM, ///< Select by next hop and group by origin station. 43 CS_BY_VIA, ///< Group by next hop. 44 CS_FROM_BY_VIA ///< Select by origin station and group by next hop. 45 }; 46 47 /** 48 * Ways of associating cargo to stations. 49 */ 50 enum CargoMode { 51 CM_WAITING, ///< Waiting cargo. 52 CM_PLANNED ///< Planned cargo. 53 }; 54 55 /** 56 * Creates a list of stations associated with cargo in the specified way, selected and grouped 57 * by the chosen criteria. 58 * @param mode Mode of association, either waiting cargo or planned cargo. 59 * @param selector Mode of grouping and selecting to be applied. 60 * @param station_id Station to be queried. 61 * @param cargo Cargo type to query for. 62 * @param other_station Other station to restrict the query with. 63 */ 64 ScriptStationList_Cargo(ScriptStationList_Cargo::CargoMode mode, ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, StationID other_station); 65 66 protected: 67 68 /** 69 * Creates an empty list. 70 */ ScriptStationList_Cargo()71 ScriptStationList_Cargo() {} 72 }; 73 74 /** 75 * Creates a list of stations associated with cargo waiting at a station. This is very generic. Use 76 * the subclasses for all practical purposes. 77 * @api ai game 78 * @ingroup ScriptList 79 */ 80 class ScriptStationList_CargoWaiting : public ScriptStationList_Cargo { 81 protected: 82 friend class ScriptStationList_Cargo; 83 84 /** 85 * Creates an empty list. 86 */ ScriptStationList_CargoWaiting()87 ScriptStationList_CargoWaiting() {} 88 89 /** 90 * Add waiting cargo to the list. 91 * @param station_id Station to query for waiting cargo. 92 * @param cargo Cargo type to query for. 93 * @param other_station Other station to restrict the query with. 94 */ 95 template<CargoSelector Tselector> 96 void Add(StationID station_id, CargoID cargo, StationID other_station = INVALID_STATION); 97 98 public: 99 100 /** 101 * Creates a list of stations associated with waiting cargo, selected and grouped by the chosen 102 * criteria. 103 * @param selector Mode of grouping and selecting to be applied. 104 * @param station_id Station to be queried. 105 * @param cargo Cargo type to query for. 106 * @param other_station Other station to restrict the query with. 107 */ 108 ScriptStationList_CargoWaiting(ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, StationID other_station); 109 }; 110 111 /** 112 * Creates a list of stations associated with cargo planned to pass a station. This is very 113 * generic. Use the subclasses for all practical purposes. 114 * @api ai game 115 * @ingroup ScriptList 116 */ 117 class ScriptStationList_CargoPlanned : public ScriptStationList_Cargo { 118 protected: 119 friend class ScriptStationList_Cargo; 120 121 /** 122 * Creates an empty list. 123 */ ScriptStationList_CargoPlanned()124 ScriptStationList_CargoPlanned() {} 125 126 /** 127 * Add planned cargo to the list. 128 * @param station_id Station to query for waiting cargo. 129 * @param cargo Cargo type to query for. 130 * @param other_station Other station to restrict the query with. 131 */ 132 template<CargoSelector Tselector> 133 void Add(StationID station_id, CargoID cargo, StationID other_station = INVALID_STATION); 134 135 public: 136 137 /** 138 * Creates a list of stations associated with cargo planned to pass the station, selected and 139 * grouped by the chosen criteria. 140 * @param selector Mode of grouping and selecting to be applied. 141 * @param station_id Station to be queried. 142 * @param cargo Cargo type to query for. 143 * @param other_station Other station to restrict the query with. 144 */ 145 ScriptStationList_CargoPlanned(ScriptStationList_Cargo::CargoSelector selector, StationID station_id, CargoID cargo, StationID other_station); 146 }; 147 148 /** 149 * Creates a list of origin stations of waiting cargo at a station, with the amounts of cargo 150 * waiting from each of those origin stations as values. 151 * @api ai game 152 * @ingroup ScriptList 153 */ 154 class ScriptStationList_CargoWaitingByFrom : public ScriptStationList_CargoWaiting { 155 public: 156 /** 157 * @param station_id Station to query for waiting cargo. 158 * @param cargo Cargo type to query for. 159 */ 160 ScriptStationList_CargoWaitingByFrom(StationID station_id, CargoID cargo); 161 }; 162 163 /** 164 * Creates a list of origin stations of cargo waiting at a station for a transfer via another 165 * station, with the amounts of cargo waiting from each of those origin stations as values. 166 * @api ai game 167 * @ingroup ScriptList 168 */ 169 class ScriptStationList_CargoWaitingViaByFrom : public ScriptStationList_CargoWaiting { 170 public: 171 /** 172 * @param station_id Station to query for waiting cargo. 173 * @param cargo Cargo type to query for. 174 * @param via Next hop to restrict the query with. 175 */ 176 ScriptStationList_CargoWaitingViaByFrom(StationID station_id, CargoID cargo, StationID via); 177 }; 178 179 /** 180 * Creates a list of next hops of waiting cargo at a station, with the amounts of cargo waiting for 181 * each of those next hops as values. 182 * @api ai game 183 * @ingroup ScriptList 184 */ 185 class ScriptStationList_CargoWaitingByVia : public ScriptStationList_CargoWaiting { 186 public: 187 /** 188 * @param station_id Station to query for waiting cargo. 189 * @param cargo Cargo type to query for. 190 */ 191 ScriptStationList_CargoWaitingByVia(StationID station_id, CargoID cargo); 192 }; 193 194 /** 195 * Creates a list of next hops of waiting cargo from a specific station at another station, with 196 * the amounts of cargo waiting for each of those next hops as values. 197 * @api ai game 198 * @ingroup ScriptList 199 */ 200 class ScriptStationList_CargoWaitingFromByVia : public ScriptStationList_CargoWaiting { 201 public: 202 /** 203 * @param station_id Station to query for waiting cargo. 204 * @param cargo Cargo type to query for. 205 * @param from Origin station to restrict the query with. 206 */ 207 ScriptStationList_CargoWaitingFromByVia(StationID station_id, CargoID cargo, StationID from); 208 }; 209 210 /** 211 * Creates a list of origin stations of cargo planned to pass a station, with the monthly amounts 212 * of cargo planned for each of those origin stations as values. 213 * @api ai game 214 * @ingroup ScriptList 215 */ 216 class ScriptStationList_CargoPlannedByFrom : public ScriptStationList_CargoPlanned { 217 public: 218 /** 219 * @param station_id Station to query for planned flows. 220 * @param cargo Cargo type to query for. 221 */ 222 ScriptStationList_CargoPlannedByFrom(StationID station_id, CargoID cargo); 223 }; 224 225 /** 226 * Creates a list of origin stations of cargo planned to pass a station going via another station, 227 * with the monthly amounts of cargo planned for each of those origin stations as values. 228 * @api ai game 229 * @ingroup ScriptList 230 */ 231 class ScriptStationList_CargoPlannedViaByFrom : public ScriptStationList_CargoPlanned { 232 public: 233 /** 234 * @param station_id Station to query for planned flows. 235 * @param cargo Cargo type to query for. 236 * @param via Next hop to restrict the query with. 237 */ 238 ScriptStationList_CargoPlannedViaByFrom(StationID station_id, CargoID cargo, StationID via); 239 }; 240 241 /** 242 * Creates a list of next hops of cargo planned to pass a station, with the monthly amounts of 243 * cargo planned for each of those next hops as values. 244 * Cargo planned to go "via" the station being queried will actually be delivered there. 245 * @api ai game 246 * @ingroup ScriptList 247 */ 248 class ScriptStationList_CargoPlannedByVia : public ScriptStationList_CargoPlanned { 249 public: 250 /** 251 * @param station_id Station to query for planned flows. 252 * @param cargo Cargo type to query for. 253 */ 254 ScriptStationList_CargoPlannedByVia(StationID station_id, CargoID cargo); 255 }; 256 257 /** 258 * Creates a list of next hops of cargo planned to pass a station and originating from another 259 * station, with the monthly amounts of cargo planned for each of those next hops as values. 260 * Cargo planned to go "via" the station being queried will actually be delivered there. 261 * @api ai game 262 * @ingroup ScriptList 263 */ 264 class ScriptStationList_CargoPlannedFromByVia : public ScriptStationList_CargoPlanned { 265 public: 266 /** 267 * @param station_id Station to query for planned flows. 268 * @param cargo Cargo type to query for. 269 * @param from Origin station to restrict the query with. 270 */ 271 ScriptStationList_CargoPlannedFromByVia(StationID station_id, CargoID cargo, StationID from); 272 }; 273 274 /** 275 * Creates a list of stations which the vehicle has in its orders. 276 * @api ai game 277 * @ingroup ScriptList 278 */ 279 class ScriptStationList_Vehicle : public ScriptList { 280 public: 281 /** 282 * @param vehicle_id The vehicle to get the list of stations it has in its orders from. 283 */ 284 ScriptStationList_Vehicle(VehicleID vehicle_id); 285 }; 286 287 #endif /* SCRIPT_STATIONLIST_HPP */ 288