(svn r23005) -Fix (r23004): Of course there's still the 16-sprite version for shore...
[openttd/fttd.git] / src / newgrf_station.h
blob7c9f80694f6ac09e97d1daef37118500892ca4b5
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
10 /** @file newgrf_station.h Header file for NewGRF stations */
12 #ifndef NEWGRF_STATION_H
13 #define NEWGRF_STATION_H
15 #include "newgrf_animation_type.h"
16 #include "newgrf_callbacks.h"
17 #include "newgrf_class.h"
18 #include "newgrf_commons.h"
19 #include "sprite.h"
20 #include "cargo_type.h"
21 #include "station_type.h"
22 #include "rail_type.h"
24 enum StationClassID {
25 STAT_CLASS_BEGIN = 0, ///< the lowest valid value
26 STAT_CLASS_DFLT = 0, ///< Default station class.
27 STAT_CLASS_WAYP, ///< Waypoint class.
28 STAT_CLASS_MAX = 32, ///< Maximum number of classes.
30 typedef SimpleTinyEnumT<StationClassID, byte> StationClassIDByte;
31 template <> struct EnumPropsT<StationClassID> : MakeEnumPropsT<StationClassID, byte, STAT_CLASS_BEGIN, STAT_CLASS_MAX, STAT_CLASS_MAX, 8> {};
33 /** Allow incrementing of StationClassID variables */
34 DECLARE_POSTFIX_INCREMENT(StationClassID)
36 enum StationSpecFlags {
37 SSF_SEPARATE_GROUND, ///< Use different sprite set for ground sprites.
38 SSF_DIV_BY_STATION_SIZE, ///< Divide cargo amount by station size.
39 SSF_CB141_RANDOM_BITS, ///< Callback 141 needs random bits.
40 SSF_CUSTOM_FOUNDATIONS, ///< Draw custom foundations.
41 SSF_EXTENDED_FOUNDATIONS, ///< Extended foundation block instead of simple.
44 /* Station layout for given dimensions - it is a two-dimensional array
45 * where index is computed as (x * platforms) + platform. */
46 typedef byte *StationLayout;
48 /** Station specification. */
49 struct StationSpec {
50 /**
51 * Properties related the the grf file.
52 * NUM_CARGO real cargo plus three pseudo cargo sprite groups.
53 * Used for obtaining the sprite offset of custom sprites, and for
54 * evaluating callbacks.
56 GRFFilePropsBase<NUM_CARGO + 3> grf_prop;
57 StationClassID cls_id; ///< The class to which this spec belongs.
58 StringID name; ///< Name of this station.
60 /**
61 * Bitmask of number of platforms available for the station.
62 * 0..6 correpsond to 1..7, while bit 7 corresponds to >7 platforms.
64 byte disallowed_platforms;
65 /**
66 * Bitmask of platform lengths available for the station.
67 * 0..6 correpsond to 1..7, while bit 7 corresponds to >7 tiles long.
69 byte disallowed_lengths;
71 /**
72 * Number of tile layouts.
73 * A minimum of 8 is required is required for stations.
74 * 0-1 = plain platform
75 * 2-3 = platform with building
76 * 4-5 = platform with roof, left side
77 * 6-7 = platform with roof, right side
79 uint tiles;
80 NewGRFSpriteLayout *renderdata; ///< Array of tile layouts.
82 /**
83 * Cargo threshold for choosing between little and lots of cargo
84 * @note little/lots are equivalent to the moving/loading states for vehicles
86 uint16 cargo_threshold;
88 uint32 cargo_triggers; ///< Bitmask of cargo types which cause trigger re-randomizing
90 byte callback_mask; ///< Bitmask of station callbacks that have to be called
92 byte flags; ///< Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size
94 byte pylons; ///< Bitmask of base tiles (0 - 7) which should contain elrail pylons
95 byte wires; ///< Bitmask of base tiles (0 - 7) which should contain elrail wires
96 byte blocked; ///< Bitmask of base tiles (0 - 7) which are blocked to trains
98 AnimationInfo animation;
100 byte lengths;
101 byte *platforms;
102 StationLayout **layouts;
103 bool copied_layouts;
106 /** Struct containing information relating to station classes. */
107 typedef NewGRFClass<StationSpec, StationClassID, STAT_CLASS_MAX> StationClass;
109 const StationSpec *GetStationSpec(TileIndex t);
111 /* Evaluate a tile's position within a station, and return the result a bitstuffed format. */
112 uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred);
114 SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32 var10 = 0);
115 SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint layout, uint edge_info);
116 uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile);
117 CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_tile, const StationSpec *statspec, Axis axis, byte plat_len, byte numtracks);
119 /* Allocate a StationSpec to a Station. This is called once per build operation. */
120 int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec);
122 /* Deallocate a StationSpec from a Station. Called when removing a single station tile. */
123 void DeallocateSpecFromStation(BaseStation *st, byte specindex);
125 /* Draw representation of a station tile for GUI purposes. */
126 bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station);
128 void AnimateStationTile(TileIndex tile);
129 void TriggerStationAnimation(BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoID cargo_type = CT_INVALID);
130 void StationUpdateAnimTriggers(BaseStation *st);
132 #endif /* NEWGRF_STATION_H */