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: truelight@0: struct Station { truelight@0: TileIndex xy; truelight@0: TileIndex bus_tile; truelight@0: TileIndex lorry_tile; 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: byte truck_stop_status; truelight@0: byte bus_stop_status; dominik@123: byte blocked_months_obsolete; 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]; 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, truelight@0: 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: dominik@55: TileIndex GetStationTileForVehicle(Vehicle *v, Station *st); dominik@55: truelight@0: void ShowStationViewWindow(int station); truelight@0: void UpdateAllStationVirtCoord(); truelight@0: truelight@0: VARDEF Station _stations[250]; darkvater@243: VARDEF bool _station_sort_dirty[MAX_PLAYERS]; darkvater@243: VARDEF bool _global_station_sort_dirty; truelight@0: truelight@0: #define DEREF_STATION(i) (&_stations[i]) truelight@0: #define FOR_ALL_STATIONS(st) for(st=_stations; st != endof(_stations); st++) truelight@0: 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: truelight@0: #endif /* STATION_H */