newgrf_station.h

Go to the documentation of this file.
00001 /* $Id: newgrf_station.h 20623 2010-08-26 15:31:40Z rubidium $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
00008  */
00009 
00012 #ifndef NEWGRF_STATION_H
00013 #define NEWGRF_STATION_H
00014 
00015 #include "newgrf_animation_type.h"
00016 #include "newgrf_callbacks.h"
00017 #include "newgrf_class.h"
00018 #include "newgrf_commons.h"
00019 #include "sprite.h"
00020 #include "direction_type.h"
00021 #include "cargo_type.h"
00022 #include "station_type.h"
00023 #include "rail_type.h"
00024 
00025 enum StationClassID {
00026   STAT_CLASS_BEGIN = 0,    
00027   STAT_CLASS_DFLT = 0,     
00028   STAT_CLASS_WAYP,         
00029   STAT_CLASS_MAX = 32,     
00030 };
00031 typedef SimpleTinyEnumT<StationClassID, byte> StationClassIDByte;
00032 template <> struct EnumPropsT<StationClassID> : MakeEnumPropsT<StationClassID, byte, STAT_CLASS_BEGIN, STAT_CLASS_MAX, STAT_CLASS_MAX, 8> {};
00033 
00035 DECLARE_POSTFIX_INCREMENT(StationClassID)
00036 
00037 enum StationSpecFlags {
00038   SSF_SEPARATE_GROUND,      
00039   SSF_DIV_BY_STATION_SIZE,  
00040   SSF_CB141_RANDOM_BITS,    
00041   SSF_CUSTOM_FOUNDATIONS,   
00042   SSF_EXTENDED_FOUNDATIONS, 
00043 };
00044 
00045 /* Station layout for given dimensions - it is a two-dimensional array
00046  * where index is computed as (x * platforms) + platform. */
00047 typedef byte *StationLayout;
00048 
00050 struct StationSpec {
00057   GRFFilePropsBase<NUM_CARGO + 3> grf_prop;
00058   StationClassID cls_id;     
00059   StringID name;             
00060 
00065   byte disallowed_platforms;
00070   byte disallowed_lengths;
00071 
00080   uint tiles;
00081   DrawTileSprites *renderdata; 
00082   bool copied_renderdata;
00083 
00088   uint16 cargo_threshold;
00089 
00090   uint32 cargo_triggers; 
00091 
00092   byte callback_mask; 
00093 
00094   byte flags; 
00095 
00096   byte pylons;  
00097   byte wires;   
00098   byte blocked; 
00099 
00100   AnimationInfo animation;
00101 
00102   byte lengths;
00103   byte *platforms;
00104   StationLayout **layouts;
00105   bool copied_layouts;
00106 };
00107 
00109 typedef NewGRFClass<StationSpec, StationClassID, STAT_CLASS_MAX> StationClass;
00110 
00111 const StationSpec *GetStationSpec(TileIndex t);
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 BaseStation *st, TileIndex tile);
00120 SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile);
00121 SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile);
00122 uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, const BaseStation *st, TileIndex tile);
00123 
00124 /* Allocate a StationSpec to a Station. This is called once per build operation. */
00125 int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec);
00126 
00127 /* Deallocate a StationSpec from a Station. Called when removing a single station tile. */
00128 void DeallocateSpecFromStation(BaseStation *st, byte specindex);
00129 
00130 /* Draw representation of a station tile for GUI purposes. */
00131 bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station);
00132 
00133 void AnimateStationTile(TileIndex tile);
00134 void TriggerStationAnimation(const BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoID cargo_type = CT_INVALID);
00135 void StationUpdateAnimTriggers(BaseStation *st);
00136 
00137 #endif /* NEWGRF_STATION_H */

Generated on Fri Dec 31 17:15:35 2010 for OpenTTD by  doxygen 1.6.1