script_station.hpp

Go to the documentation of this file.
00001 /* $Id: script_station.hpp 23624 2011-12-19 21:00:40Z truebrain $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * 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.
00006  * 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.
00007  * 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/>.
00008  */
00009 
00012 #ifndef SCRIPT_STATION_HPP
00013 #define SCRIPT_STATION_HPP
00014 
00015 #include "script_road.hpp"
00016 #include "script_basestation.hpp"
00017 #include "../../station_type.h"
00018 
00023 class ScriptStation : public ScriptBaseStation {
00024 public:
00028   enum ErrorMessages {
00030     ERR_STATION_BASE = ScriptError::ERR_CAT_STATION << ScriptError::ERR_CAT_BIT_SIZE,
00031 
00033     ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION, // [STR_ERROR_TOO_CLOSE_TO_ANOTHER_AIRPORT, STR_ERROR_TOO_CLOSE_TO_ANOTHER_STATION, STR_ERROR_TOO_CLOSE_TO_ANOTHER_DOCK]
00034 
00036     ERR_STATION_TOO_MANY_STATIONS,            // [STR_ERROR_TOO_MANY_STATIONS_LOADING, STR_ERROR_TOO_MANY_TRUCK_STOPS, STR_ERROR_TOO_MANY_BUS_STOPS]
00037 
00039     ERR_STATION_TOO_MANY_STATIONS_IN_TOWN,    // [STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT]
00040   };
00041 
00045   enum StationType {
00046     /* Note: these values represent part of the in-game StationFacility enum */
00047     STATION_TRAIN      = ::FACIL_TRAIN,      
00048     STATION_TRUCK_STOP = ::FACIL_TRUCK_STOP, 
00049     STATION_BUS_STOP   = ::FACIL_BUS_STOP,   
00050     STATION_AIRPORT    = ::FACIL_AIRPORT,    
00051     STATION_DOCK       = ::FACIL_DOCK,       
00052     STATION_ANY        = STATION_TRAIN | STATION_TRUCK_STOP | STATION_BUS_STOP | STATION_AIRPORT | STATION_DOCK, 
00053   };
00054 
00060   static bool IsValidStation(StationID station_id);
00061 
00069   static ScriptCompany::CompanyID GetOwner(StationID station_id);
00070 
00077   static StationID GetStationID(TileIndex tile);
00078 
00087   static int32 GetCargoWaiting(StationID station_id, CargoID cargo_id);
00088 
00097   static int32 GetCargoRating(StationID station_id, CargoID cargo_id);
00098 
00106   static int32 GetCoverageRadius(ScriptStation::StationType station_type);
00107 
00114   static int32 GetStationCoverageRadius(StationID station_id);
00115 
00124   static int32 GetDistanceManhattanToTile(StationID station_id, TileIndex tile);
00125 
00134   static int32 GetDistanceSquareToTile(StationID station_id, TileIndex tile);
00135 
00144   static bool IsWithinTownInfluence(StationID station_id, TownID town_id);
00145 
00153   static bool HasStationType(StationID station_id, StationType station_type);
00154 
00162   static bool HasRoadType(StationID station_id, ScriptRoad::RoadType road_type);
00163 
00174   static TownID GetNearestTown(StationID station_id);
00175 };
00176 
00177 DECLARE_ENUM_AS_BIT_SET(ScriptStation::StationType)
00178 
00179 #endif /* SCRIPT_STATION_HPP */