tron@2186: /* $Id$ */ tron@2186: truelight@0: #ifndef STATION_H truelight@0: #define STATION_H truelight@0: tron@2154: #include "player.h" matthijs@5216: #include "oldpool.h" darkvater@405: #include "sprite.h" matthijs@1247: #include "tile.h" peter1138@2963: #include "newgrf_station.h" truelight@0: truelight@0: typedef struct GoodsEntry { truelight@0: uint16 waiting_acceptance; truelight@0: byte days_since_pickup; truelight@0: byte rating; Darkvater@3347: StationID enroute_from; truelight@0: byte enroute_time; truelight@0: byte last_speed; truelight@0: byte last_age; celestar@1935: int32 feeder_profit; truelight@0: } GoodsEntry; truelight@0: celestar@1217: typedef enum RoadStopType { celestar@1217: RS_BUS, celestar@1217: RS_TRUCK celestar@1217: } RoadStopType; celestar@1217: truelight@1266: enum { truelight@1266: INVALID_STATION = 0xFFFF, celestar@3123: ROAD_STOP_LIMIT = 16, truelight@1266: }; celestar@1217: celestar@1217: typedef struct RoadStop { celestar@1217: TileIndex xy; celestar@1217: bool used; celestar@1217: byte status; truelight@4397: RoadStopID index; celestar@3431: byte num_vehicles; celestar@1551: StationID station; celestar@1217: struct RoadStop *next; celestar@1217: struct RoadStop *prev; celestar@1217: } RoadStop; celestar@1217: peter1138@3587: typedef struct StationSpecList { peter1138@3587: const StationSpec *spec; peter1138@3587: uint32 grfid; /// GRF ID of this custom station peter1138@3587: uint8 localidx; /// Station ID within GRF of station peter1138@3587: } StationSpecList; peter1138@3587: truelight@0: struct Station { truelight@0: TileIndex xy; celestar@1217: RoadStop *bus_stops; celestar@1217: RoadStop *truck_stops; truelight@0: TileIndex train_tile; truelight@0: TileIndex airport_tile; truelight@0: TileIndex dock_tile; truelight@0: Town *town; truelight@0: uint16 string_id; truelight@0: truelight@0: ViewportSign sign; truelight@0: truelight@0: uint16 had_vehicle_of_type; truelight@193: truelight@0: byte time_since_load; truelight@0: byte time_since_unload; truelight@0: byte delete_ctr; tron@2475: PlayerID owner; truelight@0: byte facilities; truelight@0: byte airport_type; truelight@0: truelight@0: // trainstation width/height truelight@0: byte trainst_w, trainst_h; truelight@0: peter1138@3587: /** List of custom stations (StationSpecs) allocated to the station */ peter1138@3786: uint8 num_specs; peter1138@3587: StationSpecList *speclist; peter1138@3587: rubidium@4289: Date build_date; truelight@0: truelight@0: //uint16 airport_flags; darkvater@393: uint32 airport_flags; celestar@1551: StationID index; truelight@0: celestar@3580: byte last_vehicle_type; truelight@0: GoodsEntry goods[NUM_CARGO]; celestar@1217: peter1138@3687: uint16 random_bits; peter1138@3687: byte waiting_triggers; peter1138@3687: celestar@1217: /* Stuff that is no longer used, but needed for conversion */ celestar@1217: TileIndex bus_tile_obsolete; celestar@1217: TileIndex lorry_tile_obsolete; celestar@1217: celestar@1217: byte truck_stop_status_obsolete; celestar@1217: byte bus_stop_status_obsolete; celestar@1217: byte blocked_months_obsolete; KUDr@5583: KUDr@5587: Rect rect; ///< Station spread out rectangle (not saved) maintained by StationRect_xxx() functions truelight@0: }; truelight@0: truelight@0: enum { rubidium@4344: FACIL_TRAIN = 0x01, rubidium@4344: FACIL_TRUCK_STOP = 0x02, rubidium@4344: FACIL_BUS_STOP = 0x04, rubidium@4344: FACIL_AIRPORT = 0x08, rubidium@4344: FACIL_DOCK = 0x10, truelight@0: }; truelight@0: truelight@0: enum { rubidium@4344: // HVOT_PENDING_DELETE = 1 << 0, // not needed anymore belugas@3554: HVOT_TRAIN = 1 << 1, belugas@3554: HVOT_BUS = 1 << 2, belugas@3554: HVOT_TRUCK = 1 << 3, celestar@1217: HVOT_AIRCRAFT = 1 << 4, belugas@3554: HVOT_SHIP = 1 << 5, matthijs@1751: /* This bit is used to mark stations. No, it does not belong here, but what matthijs@1751: * can we do? ;-) */ belugas@3554: HVOT_BUOY = 1 << 6 truelight@0: }; truelight@0: Celestar@568: enum { rubidium@4344: CA_BUS = 3, rubidium@4344: CA_TRUCK = 3, rubidium@4344: CA_AIR_OILPAD = 3, rubidium@4344: CA_TRAIN = 4, rubidium@4344: CA_AIR_HELIPORT = 4, rubidium@4344: CA_AIR_SMALL = 4, rubidium@4344: CA_AIR_LARGE = 5, rubidium@4344: CA_DOCK = 5, rubidium@4344: CA_AIR_METRO = 6, rubidium@4344: CA_AIR_INTER = 8, rubidium@4344: CA_AIR_COMMUTER = 4, rubidium@4344: CA_AIR_HELIDEPOT = 4, richk@4059: CA_AIR_INTERCON = 10, rubidium@4344: CA_AIR_HELISTATION = 4, tron@915: }; Celestar@568: tron@2498: void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius); truelight@0: tron@2498: void ShowStationViewWindow(StationID station); tron@1093: void UpdateAllStationVirtCoord(void); truelight@0: celestar@3812: /* sorter stuff */ celestar@3812: void RebuildStationLists(void); celestar@3812: void ResortStationLists(void); celestar@3812: matthijs@5216: DECLARE_OLD_POOL(Station, Station, 6, 1000) truelight@1272: matthijs@5247: static inline StationID GetMaxStationIndex(void) truelight@4354: { truelight@4354: /* TODO - This isn't the real content of the function, but truelight@4354: * with the new pool-system this will be replaced with one that matthijs@5247: * _really_ returns the highest index. Now it just returns truelight@4354: * the next safe value we are sure about everything is below. truelight@4354: */ matthijs@5247: return GetStationPoolSize() - 1; matthijs@5247: } matthijs@5247: matthijs@5247: static inline uint GetNumStations(void) matthijs@5247: { truelight@4354: return GetStationPoolSize(); truelight@4354: } truelight@4354: truelight@4346: /** truelight@4346: * Check if a station really exists. truelight@4346: */ truelight@4346: static inline bool IsValidStation(const Station *st) truelight@4346: { truelight@4346: return st->xy != 0; truelight@4346: } truelight@4346: truelight@4352: static inline bool IsValidStationID(StationID index) truelight@4352: { truelight@4352: return index < GetStationPoolSize() && IsValidStation(GetStation(index)); truelight@4352: } truelight@4352: truelight@4398: void DestroyStation(Station *st); truelight@4398: truelight@4398: static inline void DeleteStation(Station *st) truelight@4398: { truelight@4398: DestroyStation(st); truelight@4398: st->xy = 0; truelight@4398: } truelight@4398: tron@4980: #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)) truelight@1272: #define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0) truelight@919: truelight@1284: truelight@1284: /* Stuff for ROADSTOPS */ truelight@1284: matthijs@5216: DECLARE_OLD_POOL(RoadStop, RoadStop, 5, 2000) truelight@1284: truelight@4346: /** truelight@4346: * Check if a RaodStop really exists. truelight@4346: */ truelight@4346: static inline bool IsValidRoadStop(const RoadStop *rs) truelight@4346: { truelight@4346: return rs->used; truelight@4346: } truelight@4346: truelight@4398: void DestroyRoadStop(RoadStop* rs); truelight@4398: truelight@4398: static inline void DeleteRoadStop(RoadStop *rs) truelight@4398: { truelight@4398: DestroyRoadStop(rs); truelight@4398: rs->used = false; truelight@4398: } truelight@4398: tron@4981: #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)) truelight@1284: #define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0) truelight@1284: truelight@1284: /* End of stuff for ROADSTOPS */ truelight@1284: truelight@1284: peter1138@3765: void AfterLoadStations(void); tron@1424: void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, int w, int h, int rad); tron@1424: void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad); Darkvater@2436: uint GetStationPlatforms(const Station *st, TileIndex tile); celestar@3928: uint GetPlatformLength(TileIndex tile, DiagDirection dir); peter1138@5220: void MarkStationTilesDirty(const Station *st); darkvater@384: darkvater@384: peter1138@3763: const DrawTileSprites *GetStationTileLayout(byte gfx); tron@2520: void StationPickerDrawSprite(int x, int y, RailType railtype, int image); tron@2520: celestar@1217: RoadStop * GetRoadStopByTile(TileIndex tile, RoadStopType type); celestar@1217: RoadStop * GetPrimaryRoadStop(const Station *st, RoadStopType type); celestar@3123: uint GetNumRoadStops(const Station* st, RoadStopType type); truelight@1284: RoadStop * AllocateRoadStop( void ); celestar@3123: void ClearSlot(Vehicle *v); celestar@1217: matthijs@1751: static inline bool IsBuoy(const Station* st) matthijs@1751: { KUDr@3900: return (st->had_vehicle_of_type & HVOT_BUOY) != 0; /* XXX: We should really ditch this ugly coding and switch to something sane... */ matthijs@1751: } matthijs@1751: truelight@0: #endif /* STATION_H */