2005-07-24 16:12:37 +02:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-03-31 02:06:17 +02:00
|
|
|
/** @file station_base.h Base classes/functions for stations. */
|
2007-04-04 03:35:16 +02:00
|
|
|
|
2008-03-31 02:06:17 +02:00
|
|
|
#ifndef STATION_BASE_H
|
|
|
|
#define STATION_BASE_H
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2009-07-22 13:35:35 +02:00
|
|
|
#include "base_station_base.h"
|
2007-02-16 10:38:43 +01:00
|
|
|
#include "airport.h"
|
2007-06-22 13:58:59 +02:00
|
|
|
#include "cargopacket.h"
|
2007-12-21 23:50:51 +01:00
|
|
|
#include "cargo_type.h"
|
2008-03-31 08:42:26 +02:00
|
|
|
#include "vehicle_type.h"
|
2008-11-20 00:55:34 +01:00
|
|
|
#include "industry_type.h"
|
2008-03-31 08:42:26 +02:00
|
|
|
#include "core/geometry_type.hpp"
|
2007-04-20 10:00:30 +02:00
|
|
|
#include <list>
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2009-07-22 10:59:57 +02:00
|
|
|
typedef Pool<BaseStation, StationID, 32, 64000> StationPool;
|
2009-05-22 17:13:50 +02:00
|
|
|
extern StationPool _station_pool;
|
2007-08-02 10:47:56 +02:00
|
|
|
|
2007-03-08 21:50:27 +01:00
|
|
|
static const byte INITIAL_STATION_RATING = 175;
|
2007-01-14 21:00:25 +01:00
|
|
|
|
2007-03-07 13:11:48 +01:00
|
|
|
struct GoodsEntry {
|
2007-08-26 15:55:36 +02:00
|
|
|
enum AcceptancePickup {
|
|
|
|
ACCEPTANCE,
|
|
|
|
PICKUP
|
|
|
|
};
|
|
|
|
|
2007-01-14 21:00:25 +01:00
|
|
|
GoodsEntry() :
|
2007-08-26 15:55:36 +02:00
|
|
|
acceptance_pickup(0),
|
2007-06-22 19:34:04 +02:00
|
|
|
days_since_pickup(255),
|
2007-03-08 21:50:27 +01:00
|
|
|
rating(INITIAL_STATION_RATING),
|
2007-01-14 21:00:25 +01:00
|
|
|
last_speed(0),
|
2007-06-22 13:58:59 +02:00
|
|
|
last_age(255)
|
2007-01-14 21:00:25 +01:00
|
|
|
{}
|
|
|
|
|
2007-08-26 15:55:36 +02:00
|
|
|
byte acceptance_pickup;
|
2004-08-09 19:04:08 +02:00
|
|
|
byte days_since_pickup;
|
|
|
|
byte rating;
|
|
|
|
byte last_speed;
|
|
|
|
byte last_age;
|
2007-06-22 13:58:59 +02:00
|
|
|
CargoList cargo; ///< The cargo packets of cargo waiting in this station
|
2007-03-07 13:11:48 +01:00
|
|
|
};
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2009-07-18 20:39:17 +02:00
|
|
|
|
2009-06-25 17:42:03 +02:00
|
|
|
typedef SmallVector<Industry *, 2> IndustryVector;
|
|
|
|
|
2008-10-19 17:39:12 +02:00
|
|
|
/** Station data structure */
|
2009-07-22 10:59:57 +02:00
|
|
|
struct Station : SpecializedStation<Station, false> {
|
2007-08-24 21:19:18 +02:00
|
|
|
public:
|
2008-03-31 02:06:17 +02:00
|
|
|
RoadStop *GetPrimaryRoadStop(RoadStopType type) const
|
2007-08-24 21:19:18 +02:00
|
|
|
{
|
2008-03-31 02:06:17 +02:00
|
|
|
return type == ROADSTOP_BUS ? bus_stops : truck_stops;
|
2007-08-24 21:19:18 +02:00
|
|
|
}
|
|
|
|
|
2009-05-22 22:18:45 +02:00
|
|
|
RoadStop *GetPrimaryRoadStop(const struct RoadVehicle *v) const;
|
2007-08-24 21:19:18 +02:00
|
|
|
|
|
|
|
const AirportFTAClass *Airport() const
|
|
|
|
{
|
2008-12-26 19:01:15 +01:00
|
|
|
if (airport_tile == INVALID_TILE) return GetAirport(AT_DUMMY);
|
2007-08-24 21:19:18 +02:00
|
|
|
return GetAirport(airport_type);
|
|
|
|
}
|
2007-02-16 10:38:43 +01:00
|
|
|
|
2009-07-25 10:54:19 +02:00
|
|
|
RoadStop *bus_stops; ///< All the road stops
|
|
|
|
RoadStop *truck_stops; ///< All the truck stops
|
|
|
|
TileIndex airport_tile; ///< The location of the airport
|
|
|
|
TileIndex dock_tile; ///< The location of the dock
|
2008-11-20 00:55:34 +01:00
|
|
|
|
|
|
|
IndustryType indtype; ///< Industry type to get the name from
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2009-07-04 13:26:57 +02:00
|
|
|
StationHadVehicleOfTypeByte had_vehicle_of_type;
|
2004-09-10 21:02:27 +02:00
|
|
|
|
2004-08-09 19:04:08 +02:00
|
|
|
byte time_since_load;
|
|
|
|
byte time_since_unload;
|
|
|
|
byte airport_type;
|
|
|
|
|
2007-04-04 03:35:16 +02:00
|
|
|
uint64 airport_flags; ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32
|
2004-08-09 19:04:08 +02:00
|
|
|
|
2006-04-18 10:50:17 +02:00
|
|
|
byte last_vehicle_type;
|
2007-04-20 10:00:30 +02:00
|
|
|
std::list<Vehicle *> loading_vehicles;
|
2008-10-19 17:39:12 +02:00
|
|
|
GoodsEntry goods[NUM_CARGO]; ///< Goods at this station
|
2005-01-29 20:41:44 +01:00
|
|
|
|
2009-06-25 17:42:03 +02:00
|
|
|
IndustryVector industries_near; ///< Cached list of industries near the station that can accept cargo, @see DeliverGoodsToIndustry()
|
|
|
|
|
2008-12-26 19:01:15 +01:00
|
|
|
Station(TileIndex tile = INVALID_TILE);
|
2009-05-22 17:13:50 +02:00
|
|
|
~Station();
|
2007-01-14 20:18:50 +01:00
|
|
|
|
2009-07-04 13:26:57 +02:00
|
|
|
void AddFacility(StationFacility new_facility_bit, TileIndex facil_xy);
|
2007-09-09 12:13:17 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Marks the tiles of the station as dirty.
|
|
|
|
*
|
|
|
|
* @ingroup dirty
|
|
|
|
*/
|
2007-06-08 11:35:39 +02:00
|
|
|
void MarkTilesDirty(bool cargo_change) const;
|
2009-06-26 01:49:59 +02:00
|
|
|
|
2009-07-07 18:43:58 +02:00
|
|
|
void UpdateVirtCoord();
|
|
|
|
|
2009-07-24 17:18:25 +02:00
|
|
|
/* virtual */ uint GetPlatformLength(TileIndex tile, DiagDirection dir) const;
|
|
|
|
/* virtual */ uint GetPlatformLength(TileIndex tile) const;
|
2009-06-25 17:42:03 +02:00
|
|
|
void RecomputeIndustriesNear();
|
|
|
|
static void RecomputeIndustriesNearForAll();
|
|
|
|
|
2008-10-25 16:19:09 +02:00
|
|
|
uint GetCatchmentRadius() const;
|
2009-08-07 23:11:58 +02:00
|
|
|
Rect GetCatchmentRect() const;
|
2009-06-24 19:39:54 +02:00
|
|
|
|
2009-07-17 21:44:13 +02:00
|
|
|
/* virtual */ FORCEINLINE bool TileBelongsToRailStation(TileIndex tile) const
|
2009-06-26 01:49:59 +02:00
|
|
|
{
|
2009-07-24 13:47:12 +02:00
|
|
|
return IsRailStationTile(tile) && GetStationIndex(tile) == this->index;
|
2009-06-26 01:49:59 +02:00
|
|
|
}
|
|
|
|
|
2009-07-17 21:44:13 +02:00
|
|
|
/* virtual */ uint32 GetNewGRFVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) const;
|
|
|
|
|
2009-07-21 13:11:05 +02:00
|
|
|
/* virtual */ void GetTileArea(TileArea *ta, StationType type) const;
|
|
|
|
|
2009-07-05 15:20:05 +02:00
|
|
|
static void PostDestructor(size_t index);
|
2004-08-09 19:04:08 +02:00
|
|
|
};
|
|
|
|
|
2009-07-22 10:59:57 +02:00
|
|
|
#define FOR_ALL_STATIONS(var) FOR_ALL_BASE_STATIONS_OF_TYPE(Station, var)
|
2005-01-06 23:31:58 +01:00
|
|
|
|
2008-03-31 02:06:17 +02:00
|
|
|
#endif /* STATION_BASE_H */
|