newgrf_station.h

Go to the documentation of this file.
00001 /* $Id: newgrf_station.h 15436 2009-02-09 22:49:28Z peter1138 $ */
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 /* Station layout for given dimensions - it is a two-dimensional array
00033  * where index is computed as (x * platforms) + platform. */
00034 typedef byte *StationLayout;
00035 
00036 struct StationSpec {
00037   const struct GRFFile *grffile; 
00038   int localidx; 
00039 
00040   bool allocated; 
00041 
00042   StationClassID sclass; 
00043   StringID name; 
00044 
00049   byte disallowed_platforms;
00054   byte disallowed_lengths;
00055 
00063   uint tiles;
00064   DrawTileSprites *renderdata; 
00065   bool copied_renderdata;
00066 
00070   uint16 cargo_threshold;
00071 
00072   uint32 cargo_triggers; 
00073 
00074   byte callbackmask; 
00075 
00076   byte flags; 
00077 
00078   byte pylons;  
00079   byte wires;   
00080   byte blocked; 
00081 
00082   byte lengths;
00083   byte *platforms;
00084   StationLayout **layouts;
00085   bool copied_layouts;
00086 
00087   uint8  anim_frames;
00088   uint8  anim_status;
00089   uint8  anim_speed;
00090   uint16 anim_triggers;
00091 
00097   const struct SpriteGroup *spritegroup[NUM_CARGO + 3];
00098 };
00099 
00103 struct StationClass {
00104   uint32 id;          
00105   StringID name;      
00106   uint stations;      
00107   StationSpec **spec; 
00108 };
00109 
00110 void ResetStationClasses();
00111 StationClassID AllocateStationClass(uint32 cls);
00112 void SetStationClassName(StationClassID sclass, StringID name);
00113 StringID GetStationClassName(StationClassID sclass);
00114 const StationSpec *GetStationSpec(TileIndex t);
00115 
00116 uint GetNumStationClasses();
00117 uint GetNumCustomStations(StationClassID sclass);
00118 
00119 void SetCustomStationSpec(StationSpec *statspec);
00120 const StationSpec *GetCustomStationSpec(StationClassID sclass, uint station);
00121 const StationSpec *GetCustomStationSpecByGrf(uint32 grfid, byte localidx, int *index);
00122 
00123 /* Evaluate a tile's position within a station, and return the result a bitstuffed format. */
00124 uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred);
00125 
00126 /* Get sprite offset for a given custom station and station structure (may be
00127  * NULL - that means we are in a build dialog). The station structure is used
00128  * for variational sprite groups. */
00129 SpriteID GetCustomStationRelocation(const StationSpec *statspec, const Station *st, TileIndex tile);
00130 SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const Station *st, TileIndex tile);
00131 uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, const Station *st, TileIndex tile);
00132 
00133 /* Allocate a StationSpec to a Station. This is called once per build operation. */
00134 int AllocateSpecToStation(const StationSpec *statspec, Station *st, bool exec);
00135 
00136 /* Deallocate a StationSpec from a Station. Called when removing a single station tile. */
00137 void DeallocateSpecFromStation(Station *st, byte specindex);
00138 
00139 /* Draw representation of a station tile for GUI purposes. */
00140 bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station);
00141 
00142 enum StatAnimTrigger {
00143   STAT_ANIM_BUILT,
00144   STAT_ANIM_NEW_CARGO,
00145   STAT_ANIM_CARGO_TAKEN,
00146   STAT_ANIM_TRAIN_ARRIVES,
00147   STAT_ANIM_TRAIN_DEPARTS,
00148   STAT_ANIM_TRAIN_LOADS,
00149   STAT_ANIM_250_TICKS,
00150 };
00151 
00152 void AnimateStationTile(TileIndex tile);
00153 void StationAnimationTrigger(const Station *st, TileIndex tile, StatAnimTrigger trigger, CargoID cargo_type = CT_INVALID);
00154 void StationUpdateAnimTriggers(Station *st);
00155 
00156 #endif /* NEWGRF_STATION_H */

Generated on Wed Apr 1 14:38:08 2009 for OpenTTD by  doxygen 1.5.6