# newgrf_station.h

Go to the documentation of this file.

    00001 /* $Id: newgrf_station.h 16059 2009-04-14 21:07:33Z rubidium $ */
    00002
    00005 #ifndef NEWGRF_STATION_H
    00006 #define NEWGRF_STATION_H
    00007
    00008 #include "engine_type.h"
    00009 #include "newgrf_callbacks.h"
    00010 #include "newgrf_cargo.h"
    00011 #include "tile_type.h"
    00012 #include "station_type.h"
    00013 #include "strings_type.h"
    00014 #include "sprite.h"
    00015 #include "direction_type.h"
    00016 #include "newgrf.h"
    00017
    00018 enum StationClassID {
    00019   STAT_CLASS_BEGIN = 0,
    00020   STAT_CLASS_DFLT = 0,
    00021   STAT_CLASS_WAYP,
    00022   STAT_CLASS_MAX = 32,
    00023 };
    00024
    00026 template <> struct EnumPropsT<StationClassID> : MakeEnumPropsT<StationClassID, byte, STAT_CLASS_BEGIN, STAT_CLASS_MAX, STAT_CLASS_MAX> {};
    00027 typedef TinyEnumT<StationClassID> StationClassIDByte;
    00028
    00030 DECLARE_POSTFIX_INCREMENT(StationClassID);
    00031
    00032 enum StationSpecFlags {
    00033   SSF_SEPARATE_GROUND,
    00034   SSF_DIV_BY_STATION_SIZE,
    00035   SSF_CB141_RANDOM_BITS,
    00036   SSF_CUSTOM_FOUNDATIONS,
    00037   SSF_EXTENDED_FOUNDATIONS,
    00038 };
    00039
    00040 /* Station layout for given dimensions - it is a two-dimensional array
    00041  * where index is computed as (x * platforms) + platform. */
    00042 typedef byte *StationLayout;
    00043
    00044 struct StationSpec {
    00045   const struct GRFFile *grffile;
    00046   int localidx;
    00047
    00048   bool allocated;
    00049
    00050   StationClassID sclass;
    00051   StringID name;
    00052
    00057   byte disallowed_platforms;
    00062   byte disallowed_lengths;
    00063
    00071   uint tiles;
    00072   DrawTileSprites *renderdata;
    00073   bool copied_renderdata;
    00074
    00078   uint16 cargo_threshold;
    00079
    00080   uint32 cargo_triggers;
    00081
    00082   byte callbackmask;
    00083
    00084   byte flags;
    00085
    00086   byte pylons;
    00087   byte wires;
    00088   byte blocked;
    00089
    00090   byte lengths;
    00091   byte *platforms;
    00092   StationLayout **layouts;
    00093   bool copied_layouts;
    00094
    00095   uint8  anim_frames;
    00096   uint8  anim_status;
    00097   uint8  anim_speed;
    00098   uint16 anim_triggers;
    00099
    00105   const struct SpriteGroup *spritegroup[NUM_CARGO + 3];
    00106 };
    00107
    00111 struct StationClass {
    00112   uint32 id;
    00113   StringID name;
    00114   uint stations;
    00115   StationSpec **spec;
    00116 };
    00117
    00118 void ResetStationClasses();
    00119 StationClassID AllocateStationClass(uint32 cls);
    00120 void SetStationClassName(StationClassID sclass, StringID name);
    00121 StringID GetStationClassName(StationClassID sclass);
    00122 const StationSpec *GetStationSpec(TileIndex t);
    00123
    00124 uint GetNumStationClasses();
    00125 uint GetNumCustomStations(StationClassID sclass);
    00126
    00127 void SetCustomStationSpec(StationSpec *statspec);
    00128 const StationSpec *GetCustomStationSpec(StationClassID sclass, uint station);
    00129 const StationSpec *GetCustomStationSpecByGrf(uint32 grfid, byte localidx, int *index);
    00130
    00131 /* Evaluate a tile's position within a station, and return the result a bitstuffed format. */
    00132 uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred);
    00133
    00134 /* Get sprite offset for a given custom station and station structure (may be
    00135  * NULL - that means we are in a build dialog). The station structure is used
    00136  * for variational sprite groups. */
    00137 SpriteID GetCustomStationRelocation(const StationSpec *statspec, const Station *st, TileIndex tile);
    00138 SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const Station *st, TileIndex tile);
    00139 uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, const Station *st, TileIndex tile);
    00140
    00141 /* Allocate a StationSpec to a Station. This is called once per build operation. */
    00142 int AllocateSpecToStation(const StationSpec *statspec, Station *st, bool exec);
    00143
    00144 /* Deallocate a StationSpec from a Station. Called when removing a single station tile. */
    00145 void DeallocateSpecFromStation(Station *st, byte specindex);
    00146
    00147 /* Draw representation of a station tile for GUI purposes. */
    00148 bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station);
    00149
    00150 enum StatAnimTrigger {
    00151   STAT_ANIM_BUILT,
    00152   STAT_ANIM_NEW_CARGO,
    00153   STAT_ANIM_CARGO_TAKEN,
    00154   STAT_ANIM_TRAIN_ARRIVES,
    00155   STAT_ANIM_TRAIN_DEPARTS,
    00156   STAT_ANIM_TRAIN_LOADS,
    00157   STAT_ANIM_250_TICKS,
    00158 };
    00159
    00160 void AnimateStationTile(TileIndex tile);
    00161 void StationAnimationTrigger(const Station *st, TileIndex tile, StatAnimTrigger trigger, CargoID cargo_type = CT_INVALID);
    00162 void StationUpdateAnimTriggers(Station *st);
    00163
    00164 #endif /* NEWGRF_STATION_H */