OpenTTD
newgrf_station.h
Go to the documentation of this file.
1 /* $Id: newgrf_station.h 27928 2017-10-25 15:38:14Z 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 
38  /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const;
39 };
40 
45 
46  StationResolverObject(const StationSpec *statspec, BaseStation *st, TileIndex tile,
49 
51 
52  /* virtual */ ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0)
53  {
54  switch (scope) {
55  case VSG_SCOPE_SELF:
56  return &this->station_scope;
57 
58  case VSG_SCOPE_PARENT: {
59  TownScopeResolver *tsr = this->GetTown();
60  if (tsr != NULL) return tsr;
61  }
62  FALLTHROUGH;
63 
64  default:
65  return ResolverObject::GetScope(scope, relative);
66  }
67  }
68 
69  /* virtual */ const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const;
70 };
71 
77 };
79 template <> struct EnumPropsT<StationClassID> : MakeEnumPropsT<StationClassID, byte, STAT_CLASS_BEGIN, STAT_CLASS_MAX, STAT_CLASS_MAX, 8> {};
80 
83 
90 };
91 
100 };
101 
102 /* Station layout for given dimensions - it is a two-dimensional array
103  * where index is computed as (x * platforms) + platform. */
104 typedef byte *StationLayout;
105 
107 struct StationSpec {
117 
128 
137  uint tiles;
139 
145 
146  uint32 cargo_triggers;
147 
149 
150  byte flags;
151 
152  byte pylons;
153  byte wires;
154  byte blocked;
155 
156  AnimationInfo animation;
157 
158  byte lengths;
159  byte *platforms;
160  StationLayout **layouts;
161  bool copied_layouts;
162 };
163 
166 
167 const StationSpec *GetStationSpec(TileIndex t);
168 
169 /* Evaluate a tile's position within a station, and return the result a bitstuffed format. */
170 uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred);
171 
172 SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32 var10 = 0);
173 SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint layout, uint edge_info);
174 uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile);
175 CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_tile, const StationSpec *statspec, Axis axis, byte plat_len, byte numtracks);
176 
177 /* Allocate a StationSpec to a Station. This is called once per build operation. */
178 int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec);
179 
180 /* Deallocate a StationSpec from a Station. Called when removing a single station tile. */
181 void DeallocateSpecFromStation(BaseStation *st, byte specindex);
182 
183 /* Draw representation of a station tile for GUI purposes. */
184 bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station);
185 
186 void AnimateStationTile(TileIndex tile);
187 void TriggerStationAnimation(BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoID cargo_type = CT_INVALID);
190 
191 #endif /* NEWGRF_STATION_H */