# newgrf_station.h

Go to the documentation of this file.

    00001 /* $Id: newgrf_station.h 11859 2008-01-15 10:36:51Z peter1138 $ */
    00002
    00005 #ifndef NEWGRF_STATION_H
    00006 #define NEWGRF_STATION_H
    00007
    00008 #include "engine.h"
    00009 #include "newgrf_callbacks.h"
    00010 #include "newgrf_cargo.h"
    00011 #include "tile_type.h"
    00012 #include "strings_type.h"
    00013
    00014 enum StationClassID {
    00015   STAT_CLASS_BEGIN = 0,
    00016   STAT_CLASS_DFLT = 0,
    00017   STAT_CLASS_WAYP,
    00018   STAT_CLASS_MAX = 32,
    00019 };
    00020
    00022 template <> struct EnumPropsT<StationClassID> : MakeEnumPropsT<StationClassID, byte, STAT_CLASS_BEGIN, STAT_CLASS_MAX, STAT_CLASS_MAX> {};
    00023 typedef TinyEnumT<StationClassID> StationClassIDByte;
    00024
    00026 DECLARE_POSTFIX_INCREMENT(StationClassID);
    00027
    00028 /* Station layout for given dimensions - it is a two-dimensional array
    00029  * where index is computed as (x * platforms) + platform. */
    00030 typedef byte *StationLayout;
    00031
    00032 struct StationSpec {
    00033   const struct GRFFile *grffile;
    00034   int localidx;
    00035
    00036   bool allocated;
    00037
    00038   StationClassID sclass;
    00039   StringID name;
    00040
    00045   byte disallowed_platforms;
    00050   byte disallowed_lengths;
    00051
    00059   uint tiles;
    00060   DrawTileSprites *renderdata;
    00061   bool copied_renderdata;
    00062
    00066   uint16 cargo_threshold;
    00067
    00068   uint32 cargo_triggers;
    00069
    00070   byte callbackmask;
    00071
    00072   byte flags;
    00073
    00074   byte pylons;
    00075   byte wires;
    00076   byte blocked;
    00077
    00078   byte lengths;
    00079   byte *platforms;
    00080   StationLayout **layouts;
    00081   bool copied_layouts;
    00082
    00088   const struct SpriteGroup *spritegroup[NUM_CARGO + 3];
    00089 };
    00090
    00094 struct StationClass {
    00095   uint32 id;
    00096   StringID name;
    00097   uint stations;
    00098   StationSpec **spec;
    00099 };
    00100
    00101 void ResetStationClasses();
    00102 StationClassID AllocateStationClass(uint32 cls);
    00103 void SetStationClassName(StationClassID sclass, StringID name);
    00104 StringID GetStationClassName(StationClassID sclass);
    00105
    00106 uint GetNumStationClasses();
    00107 uint GetNumCustomStations(StationClassID sclass);
    00108
    00109 void SetCustomStationSpec(StationSpec *statspec);
    00110 const StationSpec *GetCustomStationSpec(StationClassID sclass, uint station);
    00111 const StationSpec *GetCustomStationSpecByGrf(uint32 grfid, byte localidx);
    00112
    00113 /* Evaluate a tile's position within a station, and return the result a bitstuffed format. */
    00114 uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred);
    00115
    00116 /* Get sprite offset for a given custom station and station structure (may be
    00117  * NULL - that means we are in a build dialog). The station structure is used
    00118  * for variational sprite groups. */
    00119 SpriteID GetCustomStationRelocation(const StationSpec *statspec, const Station *st, TileIndex tile);
    00120 SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const Station *st, TileIndex tile);
    00121 uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, const Station *st, TileIndex tile);
    00122
    00123 /* Check if a rail station tile is traversable. */
    00124 bool IsStationTileBlocked(TileIndex tile);
    00125
    00126 /* Check if a rail station tile is electrifiable. */
    00127 bool IsStationTileElectrifiable(TileIndex tile);
    00128
    00129 /* Allocate a StationSpec to a Station. This is called once per build operation. */
    00130 int AllocateSpecToStation(const StationSpec *statspec, Station *st, bool exec);
    00131
    00132 /* Deallocate a StationSpec from a Station. Called when removing a single station tile. */
    00133 void DeallocateSpecFromStation(Station* st, byte specindex);
    00134
    00135 /* Draw representation of a station tile for GUI purposes. */
    00136 bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station);
    00137
    00138 #endif /* NEWGRF_STATION_H */