OpenTTD
newgrf_station.h
Go to the documentation of this file.
1 /* $Id: newgrf_station.h 26085 2013-11-24 14:41:19Z frosch $ */
2 
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  */
9 
12 #ifndef NEWGRF_STATION_H
13 #define NEWGRF_STATION_H
14 
15 #include "newgrf_animation_type.h"
16 #include "newgrf_callbacks.h"
17 #include "newgrf_class.h"
18 #include "newgrf_commons.h"
19 #include "cargo_type.h"
20 #include "station_type.h"
21 #include "rail_type.h"
22 #include "newgrf_spritegroup.h"
23 #include "newgrf_town.h"
24 
28  struct BaseStation *st;
29  const struct StationSpec *statspec;
32 
34 
35  /* virtual */ uint32 GetRandomBits() const;
36  /* virtual */ uint32 GetTriggers() const;
37  /* virtual */ void SetTriggers(int triggers) const;
38 
39  /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
40 };
41 
46 
47  StationResolverObject(const StationSpec *statspec, BaseStation *st, TileIndex tile,
50 
52 
53  /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
54  {
55  switch (scope) {
56  case VSG_SCOPE_SELF:
57  return &this->station_scope;
58 
59  case VSG_SCOPE_PARENT: {
60  TownScopeResolver *tsr = this->GetTown();
61  if (tsr != NULL) return tsr;
62  /* FALL-THROUGH */
63  }
64 
65  default:
66  return ResolverObject::GetScope(scope, relative);
67  }
68  }
69 
70  /* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
71 };
72 
78 };
80 template <> struct EnumPropsT<StationClassID> : MakeEnumPropsT<StationClassID, byte, STAT_CLASS_BEGIN, STAT_CLASS_MAX, STAT_CLASS_MAX, 8> {};
81 
84 
91 };
92 
101 };
102 
103 /* Station layout for given dimensions - it is a two-dimensional array
104  * where index is computed as (x * platforms) + platform. */
105 typedef byte *StationLayout;
106 
108 struct StationSpec {
118 
129 
138  uint tiles;
140 
146 
147  uint32 cargo_triggers;
148 
150 
151  byte flags;
152 
153  byte pylons;
154  byte wires;
155  byte blocked;
156 
157  AnimationInfo animation;
158 
159  byte lengths;
160  byte *platforms;
161  StationLayout **layouts;
162  bool copied_layouts;
163 };
164 
167 
168 const StationSpec *GetStationSpec(TileIndex t);
169 
170 /* Evaluate a tile's position within a station, and return the result a bitstuffed format. */
171 uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred);
172 
173 SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32 var10 = 0);
174 SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint layout, uint edge_info);
175 uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile);
176 CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_tile, const StationSpec *statspec, Axis axis, byte plat_len, byte numtracks);
177 
178 /* Allocate a StationSpec to a Station. This is called once per build operation. */
179 int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec);
180 
181 /* Deallocate a StationSpec from a Station. Called when removing a single station tile. */
182 void DeallocateSpecFromStation(BaseStation *st, byte specindex);
183 
184 /* Draw representation of a station tile for GUI purposes. */
185 bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station);
186 
187 void AnimateStationTile(TileIndex tile);
188 void TriggerStationAnimation(BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoID cargo_type = CT_INVALID);
191 
192 #endif /* NEWGRF_STATION_H */