newgrf_station.h

Go to the documentation of this file.
00001 /* $Id: newgrf_station.h 17976 2009-11-05 19:46:17Z frosch $ */
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 "engine_type.h"
00016 #include "newgrf_callbacks.h"
00017 #include "tile_type.h"
00018 #include "station_type.h"
00019 #include "strings_type.h"
00020 #include "sprite.h"
00021 #include "direction_type.h"
00022 #include "newgrf.h"
00023 
00024 enum StationClassID {
00025   STAT_CLASS_BEGIN = 0,    
00026   STAT_CLASS_DFLT = 0,     
00027   STAT_CLASS_WAYP,         
00028   STAT_CLASS_MAX = 32,     
00029 };
00030 typedef SimpleTinyEnumT<StationClassID, byte> StationClassIDByte;
00031 
00033 DECLARE_POSTFIX_INCREMENT(StationClassID);
00034 
00035 enum StationSpecFlags {
00036   SSF_SEPARATE_GROUND,      
00037   SSF_DIV_BY_STATION_SIZE,  
00038   SSF_CB141_RANDOM_BITS,    
00039   SSF_CUSTOM_FOUNDATIONS,   
00040   SSF_EXTENDED_FOUNDATIONS, 
00041 };
00042 
00043 /* Station layout for given dimensions - it is a two-dimensional array
00044  * where index is computed as (x * platforms) + platform. */
00045 typedef byte *StationLayout;
00046 
00047 struct StationSpec {
00048   const struct GRFFile *grffile; 
00049   int localidx; 
00050 
00051   bool allocated; 
00052 
00053   StationClassID sclass; 
00054   StringID name; 
00055 
00060   byte disallowed_platforms;
00065   byte disallowed_lengths;
00066 
00074   uint tiles;
00075   DrawTileSprites *renderdata; 
00076   bool copied_renderdata;
00077 
00081   uint16 cargo_threshold;
00082 
00083   uint32 cargo_triggers; 
00084 
00085   byte callback_mask; 
00086 
00087   byte flags; 
00088 
00089   byte pylons;  
00090   byte wires;   
00091   byte blocked; 
00092 
00093   byte lengths;
00094   byte *platforms;
00095   StationLayout **layouts;
00096   bool copied_layouts;
00097 
00098   uint8  anim_frames;
00099   uint8  anim_status;
00100   uint8  anim_speed;
00101   uint16 anim_triggers;
00102 
00108   const struct SpriteGroup *spritegroup[NUM_CARGO + 3];
00109 };
00110 
00114 struct StationClass {
00115   uint32 id;          
00116   StringID name;      
00117   uint stations;      
00118   StationSpec **spec; 
00119 };
00120 
00121 void ResetStationClasses();
00122 StationClassID AllocateStationClass(uint32 cls);
00123 void SetStationClassName(StationClassID sclass, StringID name);
00124 StringID GetStationClassName(StationClassID sclass);
00125 const StationSpec *GetStationSpec(TileIndex t);
00126 
00127 uint GetNumStationClasses();
00128 uint GetNumCustomStations(StationClassID sclass);
00129 
00130 void SetCustomStationSpec(StationSpec *statspec);
00131 const StationSpec *GetCustomStationSpec(StationClassID sclass, uint station);
00132 const StationSpec *GetCustomStationSpecByGrf(uint32 grfid, byte localidx, int *index);
00133 
00134 /* Evaluate a tile's position within a station, and return the result a bitstuffed format. */
00135 uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred);
00136 
00137 /* Get sprite offset for a given custom station and station structure (may be
00138  * NULL - that means we are in a build dialog). The station structure is used
00139  * for variational sprite groups. */
00140 SpriteID GetCustomStationRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile);
00141 SpriteID GetCustomStationGroundRelocation(const StationSpec *statspec, const BaseStation *st, TileIndex tile);
00142 uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, const BaseStation *st, TileIndex tile);
00143 
00144 /* Allocate a StationSpec to a Station. This is called once per build operation. */
00145 int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec);
00146 
00147 /* Deallocate a StationSpec from a Station. Called when removing a single station tile. */
00148 void DeallocateSpecFromStation(BaseStation *st, byte specindex);
00149 
00150 /* Draw representation of a station tile for GUI purposes. */
00151 bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station);
00152 
00153 enum StatAnimTrigger {
00154   STAT_ANIM_BUILT,
00155   STAT_ANIM_NEW_CARGO,
00156   STAT_ANIM_CARGO_TAKEN,
00157   STAT_ANIM_TRAIN_ARRIVES,
00158   STAT_ANIM_TRAIN_DEPARTS,
00159   STAT_ANIM_TRAIN_LOADS,
00160   STAT_ANIM_250_TICKS,
00161 };
00162 
00163 void AnimateStationTile(TileIndex tile);
00164 void StationAnimationTrigger(const BaseStation *st, TileIndex tile, StatAnimTrigger trigger, CargoID cargo_type = CT_INVALID);
00165 void StationUpdateAnimTriggers(BaseStation *st);
00166 
00167 #endif /* NEWGRF_STATION_H */

Generated on Wed Dec 23 23:27:52 2009 for OpenTTD by  doxygen 1.5.6