peter1138@2625: /* $Id$ */ peter1138@2625: peter1138@2963: /** @file newgrf_station.h Header file for NewGRF stations */ peter1138@2625: peter1138@2963: #ifndef NEWGRF_STATION_H peter1138@2963: #define NEWGRF_STATION_H peter1138@2625: peter1138@2625: #include "engine.h" belugas@3866: #include "newgrf_cargo.h" peter1138@2625: peter1138@2625: typedef enum { peter1138@2625: STAT_CLASS_DFLT, ///< Default station class. peter1138@2625: STAT_CLASS_WAYP, ///< Waypoint class. peter1138@3767: STAT_CLASS_MAX = 32, ///< Maximum number of classes. peter1138@2625: } StationClassID; peter1138@2625: peter1138@2625: /* Station layout for given dimensions - it is a two-dimensional array peter1138@2625: * where index is computed as (x * platforms) + platform. */ peter1138@2625: typedef byte *StationLayout; peter1138@2625: peter1138@3688: typedef struct StationSpec { peter1138@2625: uint32 grfid; ///< ID of GRF file station belongs to. peter1138@2625: int localidx; ///< Index within GRF file of station. peter1138@2625: peter1138@3780: bool allocated; ///< Flag whether this station has been added to a station class list peter1138@3780: peter1138@2625: StationClassID sclass; ///< The class to which this spec belongs. peter1138@3594: StringID name; ///< Name of this station. peter1138@2625: peter1138@2625: /** peter1138@2625: * Bitmask of number of platforms available for the station. peter1138@2625: * 0..6 correpsond to 1..7, while bit 7 corresponds to >7 platforms. peter1138@2625: */ peter1138@3505: byte disallowed_platforms; peter1138@2625: /** peter1138@2625: * Bitmask of platform lengths available for the station. peter1138@2625: * 0..6 correpsond to 1..7, while bit 7 corresponds to >7 tiles long. peter1138@2625: */ peter1138@3505: byte disallowed_lengths; peter1138@2625: peter1138@2625: /** Number of tile layouts. peter1138@2625: * A minimum of 8 is required is required for stations. peter1138@2625: * 0-1 = plain platform peter1138@2625: * 2-3 = platform with building peter1138@2625: * 4-5 = platform with roof, left side peter1138@2625: * 6-7 = platform with roof, right side peter1138@2625: */ peter1138@3570: uint tiles; peter1138@2625: DrawTileSprites *renderdata; ///< Array of tile layouts. peter1138@3740: bool copied_renderdata; peter1138@2625: peter1138@3505: /** Cargo threshold for choosing between little and lots of cargo peter1138@3505: * @note little/lots are equivalent to the moving/loading states for vehicles peter1138@3505: */ peter1138@3505: uint16 cargo_threshold; peter1138@3505: peter1138@3505: uint32 cargo_triggers; ///< Bitmask of cargo types which cause trigger re-randomizing peter1138@3505: peter1138@3505: byte callbackmask; ///< Bitmask of callbacks to use, @see newgrf_callbacks.h peter1138@3505: peter1138@3505: byte flags; ///< Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size peter1138@3505: peter1138@3505: byte pylons; ///< Bitmask of base tiles (0 - 7) which should contain elrail pylons peter1138@3505: byte wires; ///< Bitmask of base tiles (0 - 7) which should contain elrail wires peter1138@3505: byte blocked; ///< Bitmask of base tiles (0 - 7) which are blocked to trains peter1138@3505: peter1138@2625: byte lengths; peter1138@2625: byte *platforms; peter1138@2625: StationLayout **layouts; peter1138@5060: bool copied_layouts; peter1138@2625: peter1138@2625: /** peter1138@2625: * NUM_GLOBAL_CID sprite groups. peter1138@2625: * Used for obtaining the sprite offset of custom sprites, and for peter1138@2625: * evaluating callbacks. peter1138@2625: */ peter1138@4893: const struct SpriteGroup *spritegroup[NUM_GLOBAL_CID]; peter1138@2625: } StationSpec; peter1138@2625: peter1138@2625: /** peter1138@2625: * Struct containing information relating to station classes. peter1138@2625: */ peter1138@3688: typedef struct StationClass { peter1138@2625: uint32 id; ///< ID of this class, e.g. 'DFLT', 'WAYP', etc. peter1138@3594: StringID name; ///< Name of this class. peter1138@2625: uint stations; ///< Number of stations in this class. peter1138@2625: StationSpec **spec; ///< Array of station specifications. peter1138@2625: } StationClass; peter1138@2625: peter1138@2625: void ResetStationClasses(void); KUDr@3900: StationClassID AllocateStationClass(uint32 cls); peter1138@3642: void SetStationClassName(StationClassID sclass, StringID name); peter1138@3642: StringID GetStationClassName(StationClassID sclass); peter1138@3642: StringID *BuildStationClassDropdown(void); peter1138@3642: peter1138@3587: uint GetNumStationClasses(void); peter1138@2625: uint GetNumCustomStations(StationClassID sclass); peter1138@2625: belugas@3676: void SetCustomStationSpec(StationSpec *statspec); belugas@3676: const StationSpec *GetCustomStationSpec(StationClassID sclass, uint station); peter1138@3765: const StationSpec *GetCustomStationSpecByGrf(uint32 grfid, byte localidx); peter1138@2625: peter1138@3769: /* Evaluate a tile's position within a station, and return the result a bitstuffed format. */ peter1138@3769: uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred); peter1138@3769: peter1138@2967: /* Get sprite offset for a given custom station and station structure (may be peter1138@3751: * NULL - that means we are in a build dialog). The station structure is used peter1138@3751: * for variational sprite groups. */ peter1138@3751: SpriteID GetCustomStationRelocation(const StationSpec *statspec, const Station *st, TileIndex tile); peter1138@3775: SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const Station *st, TileIndex tile); peter1138@3752: uint16 GetStationCallback(uint16 callback, uint32 param1, uint32 param2, const StationSpec *statspec, const Station *st, TileIndex tile); peter1138@2967: peter1138@3766: /* Check if a rail station tile is traversable. */ peter1138@3766: bool IsStationTileBlocked(TileIndex tile); peter1138@3766: glx@3789: /* Check if a rail station tile is electrifiable. */ glx@3789: bool IsStationTileElectrifiable(TileIndex tile); glx@3789: peter1138@3587: /* Allocate a StationSpec to a Station. This is called once per build operation. */ belugas@3676: int AllocateSpecToStation(const StationSpec *statspec, Station *st, bool exec); peter1138@3587: peter1138@3587: /* Deallocate a StationSpec from a Station. Called when removing a single station tile. */ tron@4190: void DeallocateSpecFromStation(Station* st, byte specindex); peter1138@3587: peter1138@3764: /* Draw representation of a station tile for GUI purposes. */ peter1138@3764: bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station); peter1138@3764: peter1138@2963: #endif /* NEWGRF_STATION_H */