2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#ifndef STATION_H
|
|
|
|
#define STATION_H
|
|
|
|
|
2005-07-21 19:36:43 +00:00
|
|
|
#include "player.h"
|
2005-02-03 17:22:35 +00:00
|
|
|
#include "pool.h"
|
2004-11-14 16:42:08 +00:00
|
|
|
#include "sprite.h"
|
2005-01-31 11:23:10 +00:00
|
|
|
#include "tile.h"
|
2006-02-03 15:51:00 +00:00
|
|
|
#include "newgrf_station.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
typedef struct GoodsEntry {
|
|
|
|
uint16 waiting_acceptance;
|
|
|
|
byte days_since_pickup;
|
|
|
|
byte rating;
|
2006-03-26 22:55:27 +00:00
|
|
|
StationID enroute_from;
|
2004-08-09 17:04:08 +00:00
|
|
|
byte enroute_time;
|
|
|
|
byte last_speed;
|
|
|
|
byte last_age;
|
2005-06-15 16:58:15 +00:00
|
|
|
int32 feeder_profit;
|
2004-08-09 17:04:08 +00:00
|
|
|
} GoodsEntry;
|
|
|
|
|
2005-01-29 19:41:44 +00:00
|
|
|
typedef enum RoadStopType {
|
|
|
|
RS_BUS,
|
|
|
|
RS_TRUCK
|
|
|
|
} RoadStopType;
|
|
|
|
|
2005-02-02 16:16:43 +00:00
|
|
|
enum {
|
|
|
|
INVALID_STATION = 0xFFFF,
|
2006-03-02 08:55:12 +00:00
|
|
|
ROAD_STOP_LIMIT = 16,
|
2005-02-02 16:16:43 +00:00
|
|
|
};
|
2005-01-29 19:41:44 +00:00
|
|
|
|
|
|
|
typedef struct RoadStop {
|
|
|
|
TileIndex xy;
|
|
|
|
bool used;
|
|
|
|
byte status;
|
2006-08-26 18:27:15 +00:00
|
|
|
RoadStopID index;
|
2006-04-03 14:25:32 +00:00
|
|
|
byte num_vehicles;
|
2005-03-25 10:40:58 +00:00
|
|
|
StationID station;
|
2005-01-29 19:41:44 +00:00
|
|
|
struct RoadStop *next;
|
|
|
|
struct RoadStop *prev;
|
|
|
|
} RoadStop;
|
|
|
|
|
2006-04-19 07:17:00 +00:00
|
|
|
typedef struct StationSpecList {
|
|
|
|
const StationSpec *spec;
|
|
|
|
uint32 grfid; /// GRF ID of this custom station
|
|
|
|
uint8 localidx; /// Station ID within GRF of station
|
|
|
|
} StationSpecList;
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
struct Station {
|
|
|
|
TileIndex xy;
|
2005-01-29 19:41:44 +00:00
|
|
|
RoadStop *bus_stops;
|
|
|
|
RoadStop *truck_stops;
|
2004-08-09 17:04:08 +00:00
|
|
|
TileIndex train_tile;
|
|
|
|
TileIndex airport_tile;
|
|
|
|
TileIndex dock_tile;
|
|
|
|
Town *town;
|
|
|
|
uint16 string_id;
|
|
|
|
|
|
|
|
ViewportSign sign;
|
|
|
|
|
|
|
|
uint16 had_vehicle_of_type;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
byte time_since_load;
|
|
|
|
byte time_since_unload;
|
|
|
|
byte delete_ctr;
|
2005-09-30 20:37:25 +00:00
|
|
|
PlayerID owner;
|
2004-08-09 17:04:08 +00:00
|
|
|
byte facilities;
|
|
|
|
byte airport_type;
|
|
|
|
|
|
|
|
// trainstation width/height
|
|
|
|
byte trainst_w, trainst_h;
|
|
|
|
|
2006-04-19 07:17:00 +00:00
|
|
|
/** List of custom stations (StationSpecs) allocated to the station */
|
2006-05-08 13:35:25 +00:00
|
|
|
uint8 num_specs;
|
2006-04-19 07:17:00 +00:00
|
|
|
StationSpecList *speclist;
|
|
|
|
|
2006-08-15 16:55:40 +00:00
|
|
|
Date build_date;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
//uint16 airport_flags;
|
2004-11-14 11:04:59 +00:00
|
|
|
uint32 airport_flags;
|
2005-03-25 10:40:58 +00:00
|
|
|
StationID index;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-04-18 08:50:17 +00:00
|
|
|
byte last_vehicle_type;
|
2004-08-09 17:04:08 +00:00
|
|
|
GoodsEntry goods[NUM_CARGO];
|
2005-01-29 19:41:44 +00:00
|
|
|
|
2006-04-28 20:48:45 +00:00
|
|
|
uint16 random_bits;
|
|
|
|
byte waiting_triggers;
|
|
|
|
|
2005-01-29 19:41:44 +00:00
|
|
|
/* Stuff that is no longer used, but needed for conversion */
|
|
|
|
TileIndex bus_tile_obsolete;
|
|
|
|
TileIndex lorry_tile_obsolete;
|
|
|
|
|
|
|
|
byte truck_stop_status_obsolete;
|
|
|
|
byte bus_stop_status_obsolete;
|
|
|
|
byte blocked_months_obsolete;
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2006-08-22 14:38:37 +00:00
|
|
|
FACIL_TRAIN = 0x01,
|
|
|
|
FACIL_TRUCK_STOP = 0x02,
|
|
|
|
FACIL_BUS_STOP = 0x04,
|
|
|
|
FACIL_AIRPORT = 0x08,
|
|
|
|
FACIL_DOCK = 0x10,
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2006-08-22 14:38:37 +00:00
|
|
|
// HVOT_PENDING_DELETE = 1 << 0, // not needed anymore
|
2006-04-15 03:08:14 +00:00
|
|
|
HVOT_TRAIN = 1 << 1,
|
|
|
|
HVOT_BUS = 1 << 2,
|
|
|
|
HVOT_TRUCK = 1 << 3,
|
2005-01-29 19:41:44 +00:00
|
|
|
HVOT_AIRCRAFT = 1 << 4,
|
2006-04-15 03:08:14 +00:00
|
|
|
HVOT_SHIP = 1 << 5,
|
2005-05-02 22:13:20 +00:00
|
|
|
/* This bit is used to mark stations. No, it does not belong here, but what
|
|
|
|
* can we do? ;-) */
|
2006-04-15 03:08:14 +00:00
|
|
|
HVOT_BUOY = 1 << 6
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2004-12-08 15:46:13 +00:00
|
|
|
enum {
|
2006-08-22 14:38:37 +00:00
|
|
|
CA_BUS = 3,
|
|
|
|
CA_TRUCK = 3,
|
|
|
|
CA_AIR_OILPAD = 3,
|
|
|
|
CA_TRAIN = 4,
|
|
|
|
CA_AIR_HELIPORT = 4,
|
|
|
|
CA_AIR_SMALL = 4,
|
|
|
|
CA_AIR_LARGE = 5,
|
|
|
|
CA_DOCK = 5,
|
|
|
|
CA_AIR_METRO = 6,
|
|
|
|
CA_AIR_INTER = 8,
|
|
|
|
CA_AIR_COMMUTER = 4,
|
|
|
|
CA_AIR_HELIDEPOT = 4,
|
2006-06-23 22:05:40 +00:00
|
|
|
CA_AIR_INTERCON = 10,
|
2006-08-22 14:38:37 +00:00
|
|
|
CA_AIR_HELISTATION = 4,
|
2005-01-06 18:45:28 +00:00
|
|
|
};
|
2004-12-08 15:46:13 +00:00
|
|
|
|
2005-10-07 07:35:15 +00:00
|
|
|
void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-10-07 07:35:15 +00:00
|
|
|
void ShowStationViewWindow(StationID station);
|
2005-01-22 20:23:18 +00:00
|
|
|
void UpdateAllStationVirtCoord(void);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-05-11 10:33:58 +00:00
|
|
|
/* sorter stuff */
|
|
|
|
void RebuildStationLists(void);
|
|
|
|
void ResortStationLists(void);
|
|
|
|
|
2006-10-28 11:48:21 +00:00
|
|
|
DECLARE_POOL(Station, Station, 6, 1000)
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-08-22 20:41:26 +00:00
|
|
|
static inline StationID GetStationArraySize(void)
|
|
|
|
{
|
|
|
|
/* TODO - This isn't the real content of the function, but
|
|
|
|
* with the new pool-system this will be replaced with one that
|
|
|
|
* _really_ returns the highest index + 1. Now it just returns
|
|
|
|
* the next safe value we are sure about everything is below.
|
|
|
|
*/
|
|
|
|
return GetStationPoolSize();
|
|
|
|
}
|
|
|
|
|
2006-08-22 15:33:35 +00:00
|
|
|
/**
|
|
|
|
* Check if a station really exists.
|
|
|
|
*/
|
|
|
|
static inline bool IsValidStation(const Station *st)
|
|
|
|
{
|
|
|
|
return st->xy != 0;
|
|
|
|
}
|
|
|
|
|
2006-08-22 18:15:17 +00:00
|
|
|
static inline bool IsValidStationID(StationID index)
|
|
|
|
{
|
|
|
|
return index < GetStationPoolSize() && IsValidStation(GetStation(index));
|
|
|
|
}
|
|
|
|
|
2006-08-26 19:14:02 +00:00
|
|
|
void DestroyStation(Station *st);
|
|
|
|
|
|
|
|
static inline void DeleteStation(Station *st)
|
|
|
|
{
|
|
|
|
DestroyStation(st);
|
|
|
|
st->xy = 0;
|
|
|
|
}
|
|
|
|
|
2006-10-28 11:48:21 +00:00
|
|
|
#define FOR_ALL_STATIONS_FROM(st, start) for (st = GetStation(start); st != NULL; st = (st->index + 1U < GetStationPoolSize()) ? GetStation(st->index + 1U) : NULL) if (IsValidStation(st))
|
2005-02-03 17:22:35 +00:00
|
|
|
#define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0)
|
2005-01-06 22:31:58 +00:00
|
|
|
|
2005-02-04 15:31:30 +00:00
|
|
|
|
|
|
|
/* Stuff for ROADSTOPS */
|
|
|
|
|
2006-10-28 11:51:38 +00:00
|
|
|
DECLARE_POOL(RoadStop, RoadStop, 5, 2000)
|
2005-02-04 15:31:30 +00:00
|
|
|
|
2006-08-22 15:33:35 +00:00
|
|
|
/**
|
|
|
|
* Check if a RaodStop really exists.
|
|
|
|
*/
|
|
|
|
static inline bool IsValidRoadStop(const RoadStop *rs)
|
|
|
|
{
|
|
|
|
return rs->used;
|
|
|
|
}
|
|
|
|
|
2006-08-26 19:14:02 +00:00
|
|
|
void DestroyRoadStop(RoadStop* rs);
|
|
|
|
|
|
|
|
static inline void DeleteRoadStop(RoadStop *rs)
|
|
|
|
{
|
|
|
|
DestroyRoadStop(rs);
|
|
|
|
rs->used = false;
|
|
|
|
}
|
|
|
|
|
2006-10-28 11:51:38 +00:00
|
|
|
#define FOR_ALL_ROADSTOPS_FROM(rs, start) for (rs = GetRoadStop(start); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1U) : NULL) if (IsValidRoadStop(rs))
|
2005-02-04 15:31:30 +00:00
|
|
|
#define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0)
|
|
|
|
|
|
|
|
/* End of stuff for ROADSTOPS */
|
|
|
|
|
|
|
|
|
2006-05-06 21:46:26 +00:00
|
|
|
void AfterLoadStations(void);
|
2005-03-05 18:44:26 +00:00
|
|
|
void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, int w, int h, int rad);
|
|
|
|
void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad);
|
2005-09-18 20:56:44 +00:00
|
|
|
uint GetStationPlatforms(const Station *st, TileIndex tile);
|
2006-06-01 09:41:35 +00:00
|
|
|
uint GetPlatformLength(TileIndex tile, DiagDirection dir);
|
2004-11-14 01:25:05 +00:00
|
|
|
|
|
|
|
|
2006-05-06 20:33:22 +00:00
|
|
|
const DrawTileSprites *GetStationTileLayout(byte gfx);
|
2005-10-16 09:13:04 +00:00
|
|
|
void StationPickerDrawSprite(int x, int y, RailType railtype, int image);
|
|
|
|
|
2005-01-29 19:41:44 +00:00
|
|
|
RoadStop * GetRoadStopByTile(TileIndex tile, RoadStopType type);
|
|
|
|
RoadStop * GetPrimaryRoadStop(const Station *st, RoadStopType type);
|
2006-03-02 08:55:12 +00:00
|
|
|
uint GetNumRoadStops(const Station* st, RoadStopType type);
|
2005-02-04 15:31:30 +00:00
|
|
|
RoadStop * AllocateRoadStop( void );
|
2006-03-02 08:55:12 +00:00
|
|
|
void ClearSlot(Vehicle *v);
|
2005-01-29 19:41:44 +00:00
|
|
|
|
2005-05-02 22:13:20 +00:00
|
|
|
static inline bool IsBuoy(const Station* st)
|
|
|
|
{
|
2006-05-27 16:12:16 +00:00
|
|
|
return (st->had_vehicle_of_type & HVOT_BUOY) != 0; /* XXX: We should really ditch this ugly coding and switch to something sane... */
|
2005-05-02 22:13:20 +00:00
|
|
|
}
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#endif /* STATION_H */
|