truelight@0: #ifndef STATION_H truelight@0: #define STATION_H truelight@0: darkvater@405: #include "sprite.h" truelight@0: #include "vehicle.h" truelight@0: truelight@0: typedef struct GoodsEntry { truelight@0: uint16 waiting_acceptance; truelight@0: byte days_since_pickup; truelight@0: byte rating; truelight@0: byte enroute_from; truelight@0: byte enroute_time; truelight@0: byte last_speed; truelight@0: byte last_age; truelight@0: } GoodsEntry; truelight@0: celestar@1217: typedef enum RoadStopType { celestar@1217: RS_BUS, celestar@1217: RS_TRUCK celestar@1217: } RoadStopType; celestar@1217: celestar@1217: enum { NUM_ROAD_STOPS = 250 }; celestar@1217: enum { ROAD_STOP_LIMIT = 8 }; celestar@1217: enum { NUM_SLOTS = 2 }; celestar@1217: enum { INVALID_SLOT = 0xFFFF }; celestar@1217: celestar@1217: typedef struct RoadStop { celestar@1217: TileIndex xy; celestar@1217: bool used; celestar@1217: byte status; celestar@1217: uint32 index; celestar@1217: uint16 slot[NUM_SLOTS]; celestar@1217: uint16 station; //XXX should be StationIndex celestar@1217: uint8 type; celestar@1217: struct RoadStop *next; celestar@1217: struct RoadStop *prev; celestar@1217: } RoadStop; celestar@1217: 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: // alpha_order is obsolete since savegame format 4 truelight@0: byte alpha_order_obsolete; 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; truelight@0: byte 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: darkvater@393: byte class_id; // custom graphics station class darkvater@393: byte stat_id; // custom graphics station id in the @class_id class truelight@0: uint16 build_date; truelight@0: truelight@0: //uint16 airport_flags; darkvater@393: uint32 airport_flags; truelight@0: uint16 index; truelight@0: truelight@0: VehicleID last_vehicle; truelight@0: GoodsEntry goods[NUM_CARGO]; celestar@1217: 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; truelight@0: }; truelight@0: truelight@0: enum { truelight@0: FACIL_TRAIN = 1, truelight@0: FACIL_TRUCK_STOP = 2, truelight@0: FACIL_BUS_STOP = 4, truelight@0: FACIL_AIRPORT = 8, truelight@0: FACIL_DOCK = 0x10, truelight@0: }; truelight@0: truelight@0: enum { truelight@0: // HVOT_PENDING_DELETE = 1<<0, // not needed anymore truelight@0: HVOT_TRAIN = 1<<1, truelight@0: HVOT_BUS = 1 << 2, truelight@0: HVOT_TRUCK = 1 << 3, celestar@1217: HVOT_AIRCRAFT = 1 << 4, truelight@0: HVOT_SHIP = 1 << 5, truelight@0: HVOT_BUOY = 1 << 6 truelight@0: }; truelight@0: Celestar@568: enum { Celestar@568: CA_BUS = 3, Celestar@568: CA_TRUCK = 3, Celestar@568: CA_AIR_OILPAD = 3, Celestar@568: CA_TRAIN = 4, Celestar@568: CA_AIR_HELIPORT = 4, Celestar@568: CA_AIR_SMALL = 4, Celestar@568: CA_AIR_LARGE = 5, Celestar@568: CA_DOCK = 5, tron@915: CA_AIR_METRO = 6, Celestar@568: CA_AIR_INTER = 8, tron@915: }; Celestar@568: truelight@0: void ModifyStationRatingAround(TileIndex tile, byte owner, int amount, uint radius); truelight@0: truelight@1024: TileIndex GetStationTileForVehicle(const Vehicle *v, const Station *st); dominik@55: truelight@0: void ShowStationViewWindow(int station); tron@1093: void UpdateAllStationVirtCoord(void); truelight@0: celestar@1217: VARDEF RoadStop _roadstops[NUM_ROAD_STOPS * 2]; truelight@0: VARDEF Station _stations[250]; celestar@1217: VARDEF uint _roadstops_size; truelight@919: VARDEF uint _stations_size; truelight@919: truelight@919: VARDEF SortStruct *_station_sort; truelight@919: truelight@919: static inline Station *GetStation(uint index) truelight@919: { truelight@919: assert(index < _stations_size); truelight@919: return &_stations[index]; truelight@919: } truelight@919: truelight@919: #define FOR_ALL_STATIONS(st) for(st = _stations; st != &_stations[_stations_size]; st++) truelight@919: darkvater@243: VARDEF bool _station_sort_dirty[MAX_PLAYERS]; darkvater@243: VARDEF bool _global_station_sort_dirty; truelight@0: Celestar@568: void GetProductionAroundTiles(uint *produced, uint tile, int w, int h, int rad); Celestar@568: void GetAcceptanceAroundTiles(uint *accepts, uint tile, int w, int h, int rad); truelight@0: uint GetStationPlatforms(Station *st, uint tile); darkvater@384: darkvater@384: tron@449: /* Station layout for given dimensions - it is a two-dimensional array tron@449: * where index is computed as (x * platforms) + platform. */ tron@449: typedef byte *StationLayout; tron@449: darkvater@399: struct StationSpec { darkvater@400: uint32 grfid; darkvater@400: int localidx; // per-GRFFile station index + 1; SetCustomStation() takes care of this darkvater@400: miham@438: enum StationClass { miham@438: STAT_CLASS_NONE, // unused station slot or so miham@438: STAT_CLASS_DFLT, // default station class miham@438: STAT_CLASS_WAYP, // waypoints miham@438: miham@438: /* TODO: When we actually support custom classes, they are miham@438: * going to be allocated dynamically (with some classid->sclass miham@438: * mapping, there's a TTDPatch limit on 16 custom classes in miham@438: * the whole game at the same time) with base at miham@438: * STAT_CLASS_CUSTOM. --pasky */ miham@438: STAT_CLASS_CUSTOM, // some custom class miham@438: } sclass; darkvater@400: tron@449: /* Bitmask of platform numbers/lengths available for the station. Bits tron@449: * 0..6 correspond to 1..7, while bit 7 corresponds to >7 platforms or tron@449: * lenght. */ tron@449: byte allowed_platforms; tron@449: byte allowed_lengths; tron@449: tron@449: /* Custom sprites */ darkvater@399: byte tiles; tron@449: /* 00 = plain platform tron@449: * 02 = platform with building tron@449: * 04 = platform with roof, left side tron@449: * 06 = platform with roof, right side tron@449: * tron@449: * These numbers are used for stations in NE-SW direction, or these tron@449: * numbers plus one for stations in the NW-SE direction. */ darkvater@399: DrawTileSprites renderdata[8]; darkvater@403: tron@449: /* Custom layouts */ tron@449: /* The layout array is organized like [lenghts][platforms], both being tron@449: * dynamic arrays, the field itself is length*platforms array containing tron@449: * indexes to @renderdata (only even numbers allowed) for the given tron@449: * station tile. */ tron@449: /* @lengths is length of the @platforms and @layouts arrays, that is tron@449: * number of maximal length for which the layout is defined (since tron@449: * arrays are indexed from 0, the length itself is at [length - 1]). */ tron@449: byte lengths; tron@449: /* @platforms is array of number of platforms defined for each length. tron@449: * Zero means no platforms defined. */ tron@449: byte *platforms; tron@449: /* @layout is @layouts-sized array of @platforms-sized arrays, tron@449: * containing pointers to length*platforms-sized arrays or NULL if tron@449: * default OTTD station layout should be used for stations of these tron@449: * dimensions. */ tron@449: StationLayout **layouts; tron@449: darkvater@408: /* Sprite offsets for renderdata->seq->image. spritegroup[0] is default darkvater@408: * whilst spritegroup[1] is "CID_PURCHASE". */ darkvater@408: struct SpriteGroup spritegroup[2]; darkvater@399: }; darkvater@399: darkvater@400: /* Here, @stid is local per-GRFFile station index. If spec->localidx is not yet darkvater@400: * set, it gets new dynamically allocated global index and spec->localidx is darkvater@400: * set to @stid, otherwise we take it as that we are replacing it and try to darkvater@400: * search for it first (that isn't much fast but we do it only very seldom). */ darkvater@399: void SetCustomStation(byte stid, struct StationSpec *spec); darkvater@400: /* Here, @stid is global station index (in continous range 0..GetCustomStationsCount()) darkvater@400: * (lookup is therefore very fast as we do this very frequently). */ miham@438: struct StationSpec *GetCustomStation(enum StationClass sclass, byte stid); darkvater@408: /* Get sprite offset for a given custom station and station structure (may be darkvater@408: * NULL if ctype is set - that means we are in a build dialog). The station darkvater@408: * structure is used for variational sprite groups. */ darkvater@408: uint32 GetCustomStationRelocation(struct StationSpec *spec, struct Station *stat, byte ctype); miham@438: int GetCustomStationsCount(enum StationClass sclass); celestar@389: celestar@1217: RoadStop * GetRoadStopByTile(TileIndex tile, RoadStopType type); celestar@1217: inline int GetRoadStopType(TileIndex tile); celestar@1217: uint GetNumRoadStops(const Station *st, RoadStopType type); celestar@1217: RoadStop * GetPrimaryRoadStop(const Station *st, RoadStopType type); celestar@1217: RoadStop * GetFirstFreeRoadStop( void ); celestar@1217: truelight@0: #endif /* STATION_H */