# station_base.h

Go to the documentation of this file.

    00001 /* $Id: station_base.h 18377 2009-12-02 16:20:44Z rubidium $ */
    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 STATION_BASE_H
    00013 #define STATION_BASE_H
    00014
    00015 #include "base_station_base.h"
    00016 #include "airport.h"
    00017 #include "cargopacket.h"
    00018 #include "cargo_type.h"
    00019 #include "industry_type.h"
    00020 #include "core/geometry_type.hpp"
    00021 #include <list>
    00022
    00023 typedef Pool<BaseStation, StationID, 32, 64000> StationPool;
    00024 extern StationPool _station_pool;
    00025
    00026 static const byte INITIAL_STATION_RATING = 175;
    00027
    00028 struct GoodsEntry {
    00029   enum AcceptancePickup {
    00030     ACCEPTANCE,
    00031     PICKUP
    00032   };
    00033
    00034   GoodsEntry() :
    00035     acceptance_pickup(0),
    00036     days_since_pickup(255),
    00037     rating(INITIAL_STATION_RATING),
    00038     last_speed(0),
    00039     last_age(255)
    00040   {}
    00041
    00042   byte acceptance_pickup;
    00043   byte days_since_pickup;
    00044   byte rating;
    00045   byte last_speed;
    00046   byte last_age;
    00047   StationCargoList cargo;
    00048 };
    00049
    00050
    00051 typedef SmallVector<Industry *, 2> IndustryVector;
    00052
    00054 struct Station : SpecializedStation<Station, false> {
    00055 public:
    00056   RoadStop *GetPrimaryRoadStop(RoadStopType type) const
    00057   {
    00058     return type == ROADSTOP_BUS ? bus_stops : truck_stops;
    00059   }
    00060
    00061   RoadStop *GetPrimaryRoadStop(const struct RoadVehicle *v) const;
    00062
    00063   const AirportFTAClass *Airport() const
    00064   {
    00065     if (airport_tile == INVALID_TILE) return GetAirport(AT_DUMMY);
    00066     return GetAirport(airport_type);
    00067   }
    00068
    00069   RoadStop *bus_stops;
    00070   TileArea bus_station;
    00071   RoadStop *truck_stops;
    00072   TileArea truck_station;
    00073
    00074   TileIndex airport_tile;
    00075   TileIndex dock_tile;
    00076
    00077   IndustryType indtype;
    00078
    00079   StationHadVehicleOfTypeByte had_vehicle_of_type;
    00080
    00081   byte time_since_load;
    00082   byte time_since_unload;
    00083   byte airport_type;
    00084
    00085   uint64 airport_flags;
    00086
    00087   byte last_vehicle_type;
    00088   std::list<Vehicle *> loading_vehicles;
    00089   GoodsEntry goods[NUM_CARGO];
    00090   uint32 always_accepted;
    00091
    00092   IndustryVector industries_near;
    00093
    00094   Station(TileIndex tile = INVALID_TILE);
    00095   ~Station();
    00096
    00097   void AddFacility(StationFacility new_facility_bit, TileIndex facil_xy);
    00098
    00104   void MarkTilesDirty(bool cargo_change) const;
    00105
    00106   void UpdateVirtCoord();
    00107
    00108   /* virtual */ uint GetPlatformLength(TileIndex tile, DiagDirection dir) const;
    00109   /* virtual */ uint GetPlatformLength(TileIndex tile) const;
    00110   void RecomputeIndustriesNear();
    00111   static void RecomputeIndustriesNearForAll();
    00112
    00113   uint GetCatchmentRadius() const;
    00114   Rect GetCatchmentRect() const;
    00115
    00116   /* virtual */ FORCEINLINE bool TileBelongsToRailStation(TileIndex tile) const
    00117   {
    00118     return IsRailStationTile(tile) && GetStationIndex(tile) == this->index;
    00119   }
    00120
    00121   /* virtual */ uint32 GetNewGRFVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) const;
    00122
    00123   /* virtual */ void GetTileArea(TileArea *ta, StationType type) const;
    00124 };
    00125
    00126 #define FOR_ALL_STATIONS(var) FOR_ALL_BASE_STATIONS_OF_TYPE(Station, var)
    00127
    00128 #endif /* STATION_BASE_H */