OpenTTD Source: src/newgrf_station.cpp Source File

OpenTTD Source 12.2

newgrf_station.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
7
10 #include "stdafx.h"
11 #include "debug.h"
12 #include "station_base.h"
13 #include "waypoint_base.h"
14 #include "roadstop_base.h"
15 #include "newgrf_cargo.h"
16 #include "newgrf_station.h"
17 #include "newgrf_spritegroup.h"
18 #include "newgrf_sound.h"
19 #include "newgrf_railtype.h"
20 #include "town.h"
21 #include "newgrf_town.h"
22 #include "company_func.h"
23 #include "tunnelbridge_map.h"
24 #include "newgrf_animation_base.h"
25 #include "newgrf_class_func.h"
26
27 #include "safeguards.h"
28
29
30 template <typename Tspec, typename Tid, Tid Tmax>
31 /* static */ void NewGRFClass<Tspec, Tid, Tmax>::InsertDefaults()
32 {
33 /* Set up initial data */
34 classes[0].global_id = 'DFLT';
35 classes[0].name = STR_STATION_CLASS_DFLT;
36 classes[0].Insert(nullptr);
37
38 classes[1].global_id = 'WAYP';
39 classes[1].name = STR_STATION_CLASS_WAYP;
40 classes[1].Insert(nullptr);
41 }
42
43 template <typename Tspec, typename Tid, Tid Tmax>
44 bool NewGRFClass<Tspec, Tid, Tmax>::IsUIAvailable(uint index) const
45 {
46 return true;
47 }
48
49 INSTANTIATE_NEWGRF_CLASS_METHODS(StationClass, StationSpec, StationClassID, STAT_CLASS_MAX)
50
51 static const uint NUM_STATIONSSPECS_PER_STATION = 255;
52
53 enum TriggerArea {
54 TA_TILE,
55 TA_PLATFORM,
56 TA_WHOLE,
57 };
58
59 struct ETileArea : TileArea {
60 ETileArea(const BaseStation *st, TileIndex tile, TriggerArea ta)
61 {
62 switch (ta) {
63 default: NOT_REACHED();
64
65 case TA_TILE:
66 this->tile = tile;
67 this->w = 1;
68 this->h = 1;
69 break;
70
71 case TA_PLATFORM: {
72 TileIndex start, end;
73 Axis axis = GetRailStationAxis(tile);
74 TileIndexDiff delta = TileOffsByDiagDir(AxisToDiagDir(axis));
75
76 for (end = tile; IsRailStationTile(end + delta) && IsCompatibleTrainStationTile(end + delta, tile); end += delta) { /* Nothing */ }
77 for (start = tile; IsRailStationTile(start - delta) && IsCompatibleTrainStationTile(start - delta, tile); start -= delta) { /* Nothing */ }
78
79 this->tile = start;
80 this->w = TileX(end) - TileX(start) + 1;
81 this->h = TileY(end) - TileY(start) + 1;
82 break;
83 }
84
85 case TA_WHOLE:
86 st->GetTileArea(this, Station::IsExpected(st) ? STATION_RAIL : STATION_WAYPOINT);
87 break;
88 }
89 }
90 };
91
92
105 uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred)
106 {
107 uint32 retval = 0;
108
109 if (axis == AXIS_X) {
110 Swap(platforms, length);
111 Swap(x, y);
112 }
113
114 if (centred) {
115 x -= platforms / 2;
116 y -= length / 2;
117 x = Clamp(x, -8, 7);
118 y = Clamp(y, -8, 7);
119 SB(retval, 0, 4, y & 0xF);
120 SB(retval, 4, 4, x & 0xF);
121 } else {
122 SB(retval, 0, 4, std::min(15, y));
123 SB(retval, 4, 4, std::min(15, length - y - 1));
124 SB(retval, 8, 4, std::min(15, x));
125 SB(retval, 12, 4, std::min(15, platforms - x - 1));
126 }
127 SB(retval, 16, 4, std::min(15, length));
128 SB(retval, 20, 4, std::min(15, platforms));
129 SB(retval, 24, 4, tile);
130
131 return retval;
132 }
133
134
143 static TileIndex FindRailStationEnd(TileIndex tile, TileIndexDiff delta, bool check_type, bool check_axis)
144 {
145 byte orig_type = 0;
146 Axis orig_axis = AXIS_X;
147 StationID sid = GetStationIndex(tile);
148
149 if (check_type) orig_type = GetCustomStationSpecIndex(tile);
150 if (check_axis) orig_axis = GetRailStationAxis(tile);
151
152 for (;;) {
153 TileIndex new_tile = TILE_ADD(tile, delta);
154
155 if (!IsTileType(new_tile, MP_STATION) || GetStationIndex(new_tile) != sid) break;
156 if (!HasStationRail(new_tile)) break;
157 if (check_type && GetCustomStationSpecIndex(new_tile) != orig_type) break;
158 if (check_axis && GetRailStationAxis(new_tile) != orig_axis) break;
159
160 tile = new_tile;
161 }
162 return tile;
163 }
164
165
166 static uint32 GetPlatformInfoHelper(TileIndex tile, bool check_type, bool check_axis, bool centred)
167 {
168 int tx = TileX(tile);
169 int ty = TileY(tile);
170 int sx = TileX(FindRailStationEnd(tile, TileDiffXY(-1, 0), check_type, check_axis));
171 int sy = TileY(FindRailStationEnd(tile, TileDiffXY( 0, -1), check_type, check_axis));
172 int ex = TileX(FindRailStationEnd(tile, TileDiffXY( 1, 0), check_type, check_axis)) + 1;
173 int ey = TileY(FindRailStationEnd(tile, TileDiffXY( 0, 1), check_type, check_axis)) + 1;
174
175 tx -= sx; ex -= sx;
176 ty -= sy; ey -= sy;
177
178 return GetPlatformInfo(GetRailStationAxis(tile), GetStationGfx(tile), ex, ey, tx, ty, centred);
179 }
180
181
182 static uint32 GetRailContinuationInfo(TileIndex tile)
183 {
184 /* Tile offsets and exit dirs for X axis */
185 static const Direction x_dir[8] = { DIR_SW, DIR_NE, DIR_SE, DIR_NW, DIR_S, DIR_E, DIR_W, DIR_N };
186 static const DiagDirection x_exits[8] = { DIAGDIR_SW, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NE, DIAGDIR_SW, DIAGDIR_NE };
187
188 /* Tile offsets and exit dirs for Y axis */
189 static const Direction y_dir[8] = { DIR_SE, DIR_NW, DIR_SW, DIR_NE, DIR_S, DIR_W, DIR_E, DIR_N };
190 static const DiagDirection y_exits[8] = { DIAGDIR_SE, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_NW };
191
192 Axis axis = GetRailStationAxis(tile);
193
194 /* Choose appropriate lookup table to use */
195 const Direction *dir = axis == AXIS_X ? x_dir : y_dir;
196 const DiagDirection *diagdir = axis == AXIS_X ? x_exits : y_exits;
197
198 uint32 res = 0;
199 uint i;
200
201 for (i = 0; i < lengthof(x_dir); i++, dir++, diagdir++) {
202 TileIndex neighbour_tile = tile + TileOffsByDir(*dir);
203 TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(neighbour_tile, TRANSPORT_RAIL, 0));
204 if (trackbits != TRACK_BIT_NONE) {
205 /* If there is any track on the tile, set the bit in the second byte */
206 SetBit(res, i + 8);
207
208 /* With tunnels and bridges the tile has tracks, but they are not necessarily connected
209 * with the next tile because the ramp is not going in the right direction. */
210 if (IsTileType(neighbour_tile, MP_TUNNELBRIDGE) && GetTunnelBridgeDirection(neighbour_tile) != *diagdir) {
211 continue;
212 }
213
214 /* If any track reaches our exit direction, set the bit in the lower byte */
215 if (trackbits & DiagdirReachesTracks(*diagdir)) SetBit(res, i);
216 }
217 }
218
219 return res;
220 }
221
222
223 /* Station Resolver Functions */
224 /* virtual */ uint32 StationScopeResolver::GetRandomBits() const
225 {
226 return (this->st == nullptr ? 0 : this->st->random_bits) | (this->tile == INVALID_TILE ? 0 : GetStationTileRandomBits(this->tile) << 16);
227 }
228
229
230 /* virtual */ uint32 StationScopeResolver::GetTriggers() const
231 {
232 return this->st == nullptr ? 0 : this->st->waiting_triggers;
233 }
234
235
241 static struct {
242 uint32 v40;
243 uint32 v41;
244 uint32 v45;
245 uint32 v46;
246 uint32 v47;
247 uint32 v49;
248 uint8 valid;
249 } _svc;
250
256 TownScopeResolver *StationResolverObject::GetTown()
257 {
258 if (this->town_scope == nullptr) {
259 Town *t = nullptr;
260 if (this->station_scope.st != nullptr) {
261 t = this->station_scope.st->town;
262 } else if (this->station_scope.tile != INVALID_TILE) {
263 t = ClosestTownFromTile(this->station_scope.tile, UINT_MAX);
264 }
265 if (t == nullptr) return nullptr;
266 this->town_scope = new TownScopeResolver(*this, t, this->station_scope.st == nullptr);
267 }
268 return this->town_scope;
269 }
270
271 /* virtual */ uint32 StationScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const
272 {
273 if (this->st == nullptr) {
274 /* Station does not exist, so we're in a purchase list or the land slope check callback. */
275 switch (variable) {
276 case 0x40:
277 case 0x41:
278 case 0x46:
279 case 0x47:
280 case 0x49: return 0x2110000; // Platforms, tracks & position
281 case 0x42: return 0; // Rail type (XXX Get current type from GUI?)
282 case 0x43: return GetCompanyInfo(_current_company); // Station owner
283 case 0x44: return 2; // PBS status
284 case 0x67: // Land info of nearby tile
285 if (this->axis != INVALID_AXIS && this->tile != INVALID_TILE) {
286 TileIndex tile = this->tile;
287 if (parameter != 0) tile = GetNearbyTile(parameter, tile, true, this->axis); // only perform if it is required
288
289 Slope tileh = GetTileSlope(tile);
290 bool swap = (this->axis == AXIS_Y && HasBit(tileh, CORNER_W) != HasBit(tileh, CORNER_E));
291
292 return GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8) ^ (swap ? SLOPE_EW : 0);
293 }
294 break;
295
296 case 0xFA: return Clamp(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); // Build date, clamped to a 16 bit value
297 }
298
299 *available = false;
300 return UINT_MAX;
301 }
302
303 switch (variable) {
304 /* Calculated station variables */
305 case 0x40:
306 if (!HasBit(_svc.valid, 0)) { _svc.v40 = GetPlatformInfoHelper(this->tile, false, false, false); SetBit(_svc.valid, 0); }
307 return _svc.v40;
308
309 case 0x41:
310 if (!HasBit(_svc.valid, 1)) { _svc.v41 = GetPlatformInfoHelper(this->tile, true, false, false); SetBit(_svc.valid, 1); }
311 return _svc.v41;
312
313 case 0x42: return GetTerrainType(this->tile) | (GetReverseRailTypeTranslation(GetRailType(this->tile), this->statspec->grf_prop.grffile) << 8);
314 case 0x43: return GetCompanyInfo(this->st->owner); // Station owner
315 case 0x44: return HasStationReservation(this->tile) ? 7 : 4; // PBS status
316 case 0x45:
317 if (!HasBit(_svc.valid, 2)) { _svc.v45 = GetRailContinuationInfo(this->tile); SetBit(_svc.valid, 2); }
318 return _svc.v45;
319
320 case 0x46:
321 if (!HasBit(_svc.valid, 3)) { _svc.v46 = GetPlatformInfoHelper(this->tile, false, false, true); SetBit(_svc.valid, 3); }
322 return _svc.v46;
323
324 case 0x47:
325 if (!HasBit(_svc.valid, 4)) { _svc.v47 = GetPlatformInfoHelper(this->tile, true, false, true); SetBit(_svc.valid, 4); }
326 return _svc.v47;
327
328 case 0x49:
329 if (!HasBit(_svc.valid, 5)) { _svc.v49 = GetPlatformInfoHelper(this->tile, false, true, false); SetBit(_svc.valid, 5); }
330 return _svc.v49;
331
332 case 0x4A: // Animation frame of tile
333 return GetAnimationFrame(this->tile);
334
335 /* Variables which use the parameter */
336 /* Variables 0x60 to 0x65 and 0x69 are handled separately below */
337 case 0x66: { // Animation frame of nearby tile
338 TileIndex tile = this->tile;
339 if (parameter != 0) tile = GetNearbyTile(parameter, tile);
340 return this->st->TileBelongsToRailStation(tile) ? GetAnimationFrame(tile) : UINT_MAX;
341 }
342
343 case 0x67: { // Land info of nearby tile
344 Axis axis = GetRailStationAxis(this->tile);
345 TileIndex tile = this->tile;
346 if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required
347
348 Slope tileh = GetTileSlope(tile);
349 bool swap = (axis == AXIS_Y && HasBit(tileh, CORNER_W) != HasBit(tileh, CORNER_E));
350
351 return GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8) ^ (swap ? SLOPE_EW : 0);
352 }
353
354 case 0x68: { // Station info of nearby tiles
355 TileIndex nearby_tile = GetNearbyTile(parameter, this->tile);
356
357 if (!HasStationTileRail(nearby_tile)) return 0xFFFFFFFF;
358
359 uint32 grfid = this->st->speclist[GetCustomStationSpecIndex(this->tile)].grfid;
360 bool perpendicular = GetRailStationAxis(this->tile) != GetRailStationAxis(nearby_tile);
361 bool same_station = this->st->TileBelongsToRailStation(nearby_tile);
362 uint32 res = GB(GetStationGfx(nearby_tile), 1, 2) << 12 | !!perpendicular << 11 | !!same_station << 10;
363
364 if (IsCustomStationSpecIndex(nearby_tile)) {
365 const StationSpecList ssl = BaseStation::GetByTile(nearby_tile)->speclist[GetCustomStationSpecIndex(nearby_tile)];
366 res |= 1 << (ssl.grfid != grfid ? 9 : 8) | ssl.localidx;
367 }
368 return res;
369 }
370
371 case 0x6A: { // GRFID of nearby station tiles
372 TileIndex nearby_tile = GetNearbyTile(parameter, this->tile);
373
374 if (!HasStationTileRail(nearby_tile)) return 0xFFFFFFFF;
375 if (!IsCustomStationSpecIndex(nearby_tile)) return 0;
376
377 const StationSpecList ssl = BaseStation::GetByTile(nearby_tile)->speclist[GetCustomStationSpecIndex(nearby_tile)];
378 return ssl.grfid;
379 }
380
381 /* General station variables */
382 case 0x82: return 50;
383 case 0x84: return this->st->string_id;
384 case 0x86: return 0;
385 case 0xF0: return this->st->facilities;
386 case 0xFA: return Clamp(this->st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535);
387 }
388
389 return this->st->GetNewGRFVariable(this->ro, variable, parameter, available);
390 }
391
392 uint32 Station::GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const
393 {
394 switch (variable) {
395 case 0x48: { // Accepted cargo types
396 CargoID cargo_type;
397 uint32 value = 0;
398
399 for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
400 if (HasBit(this->goods[cargo_type].status, GoodsEntry::GES_ACCEPTANCE)) SetBit(value, cargo_type);
401 }
402 return value;
403 }
404
405 case 0x8A: return this->had_vehicle_of_type;
406 case 0xF1: return (this->airport.tile != INVALID_TILE) ? this->airport.GetSpec()->ttd_airport_type : ATP_TTDP_LARGE;
407 case 0xF2: return (this->truck_stops != nullptr) ? this->truck_stops->status : 0;
408 case 0xF3: return (this->bus_stops != nullptr) ? this->bus_stops->status : 0;
409 case 0xF6: return this->airport.flags;
410 case 0xF7: return GB(this->airport.flags, 8, 8);
411 }
412
413 /* Handle cargo variables with parameter, 0x60 to 0x65 and 0x69 */
414 if ((variable >= 0x60 && variable <= 0x65) || variable == 0x69) {
415 CargoID c = GetCargoTranslation(parameter, object.grffile);
416
417 if (c == CT_INVALID) {
418 switch (variable) {
419 case 0x62: return 0xFFFFFFFF;
420 case 0x64: return 0xFF00;
421 default: return 0;
422 }
423 }
424 const GoodsEntry *ge = &this->goods[c];
425
426 switch (variable) {
427 case 0x60: return std::min(ge->cargo.TotalCount(), 4095u);
428 case 0x61: return ge->HasVehicleEverTriedLoading() ? ge->time_since_pickup : 0;
429 case 0x62: return ge->HasRating() ? ge->rating : 0xFFFFFFFF;
430 case 0x63: return ge->cargo.DaysInTransit();
431 case 0x64: return ge->HasVehicleEverTriedLoading() ? ge->last_speed | (ge->last_age << 8) : 0xFF00;
432 case 0x65: return GB(ge->status, GoodsEntry::GES_ACCEPTANCE, 1) << 3;
433 case 0x69: {
434 static_assert((int)GoodsEntry::GES_EVER_ACCEPTED + 1 == (int)GoodsEntry::GES_LAST_MONTH);
435 static_assert((int)GoodsEntry::GES_EVER_ACCEPTED + 2 == (int)GoodsEntry::GES_CURRENT_MONTH);
436 static_assert((int)GoodsEntry::GES_EVER_ACCEPTED + 3 == (int)GoodsEntry::GES_ACCEPTED_BIGTICK);
437 return GB(ge->status, GoodsEntry::GES_EVER_ACCEPTED, 4);
438 }
439 }
440 }
441
442 /* Handle cargo variables (deprecated) */
443 if (variable >= 0x8C && variable <= 0xEC) {
444 const GoodsEntry *g = &this->goods[GB(variable - 0x8C, 3, 4)];
445 switch (GB(variable - 0x8C, 0, 3)) {
446 case 0: return g->cargo.TotalCount();
447 case 1: return GB(std::min(g->cargo.TotalCount(), 4095u), 0, 4) | (GB(g->status, GoodsEntry::GES_ACCEPTANCE, 1) << 7);
448 case 2: return g->time_since_pickup;
449 case 3: return g->rating;
450 case 4: return g->cargo.Source();
451 case 5: return g->cargo.DaysInTransit();
452 case 6: return g->last_speed;
453 case 7: return g->last_age;
454 }
455 }
456
457 Debug(grf, 1, "Unhandled station variable 0x{:X}", variable);
458
459 *available = false;
460 return UINT_MAX;
461 }
462
463 uint32 Waypoint::GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const
464 {
465 switch (variable) {
466 case 0x48: return 0; // Accepted cargo types
467 case 0x8A: return HVOT_WAYPOINT;
468 case 0xF1: return 0; // airport type
469 case 0xF2: return 0; // truck stop status
470 case 0xF3: return 0; // bus stop status
471 case 0xF6: return 0; // airport flags
472 case 0xF7: return 0; // airport flags cont.
473 }
474
475 /* Handle cargo variables with parameter, 0x60 to 0x65 */
476 if (variable >= 0x60 && variable <= 0x65) {
477 return 0;
478 }
479
480 /* Handle cargo variables (deprecated) */
481 if (variable >= 0x8C && variable <= 0xEC) {
482 switch (GB(variable - 0x8C, 0, 3)) {
483 case 3: return INITIAL_STATION_RATING;
484 case 4: return INVALID_STATION;
485 default: return 0;
486 }
487 }
488
489 Debug(grf, 1, "Unhandled station variable 0x{:X}", variable);
490
491 *available = false;
492 return UINT_MAX;
493 }
494
495 /* virtual */ const SpriteGroup *StationResolverObject::ResolveReal(const RealSpriteGroup *group) const
496 {
497 if (this->station_scope.st == nullptr || this->station_scope.statspec->cls_id == STAT_CLASS_WAYP) {
498 return group->loading[0];
499 }
500
501 uint cargo = 0;
502 const Station *st = Station::From(this->station_scope.st);
503
504 switch (this->station_scope.cargo_type) {
505 case CT_INVALID:
506 case CT_DEFAULT_NA:
507 case CT_PURCHASE:
508 cargo = 0;
509 break;
510
511 case CT_DEFAULT:
512 for (CargoID cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
513 cargo += st->goods[cargo_type].cargo.TotalCount();
514 }
515 break;
516
517 default:
518 cargo = st->goods[this->station_scope.cargo_type].cargo.TotalCount();
519 break;
520 }
521
522 if (HasBit(this->station_scope.statspec->flags, SSF_DIV_BY_STATION_SIZE)) cargo /= (st->train_station.w + st->train_station.h);
523 cargo = std::min(0xfffu, cargo);
524
525 if (cargo > this->station_scope.statspec->cargo_threshold) {
526 if (!group->loading.empty()) {
527 uint set = ((cargo - this->station_scope.statspec->cargo_threshold) * (uint)group->loading.size()) / (4096 - this->station_scope.statspec->cargo_threshold);
528 return group->loading[set];
529 }
530 } else {
531 if (!group->loaded.empty()) {
532 uint set = (cargo * (uint)group->loaded.size()) / (this->station_scope.statspec->cargo_threshold + 1);
533 return group->loaded[set];
534 }
535 }
536
537 return group->loading[0];
538 }
539
540 GrfSpecFeature StationResolverObject::GetFeature() const
541 {
542 return GSF_STATIONS;
543 }
544
545 uint32 StationResolverObject::GetDebugID() const
546 {
547 return this->station_scope.statspec->grf_prop.local_id;
548 }
549
559 StationResolverObject::StationResolverObject(const StationSpec *statspec, BaseStation *base_station, TileIndex tile,
560 CallbackID callback, uint32 callback_param1, uint32 callback_param2)
561 : ResolverObject(statspec->grf_prop.grffile, callback, callback_param1, callback_param2),
562 station_scope(*this, statspec, base_station, tile), town_scope(nullptr)
563 {
564 /* Invalidate all cached vars */
565 _svc.valid = 0;
566
567 CargoID ctype = CT_DEFAULT_NA;
568
569 if (this->station_scope.st == nullptr) {
570 /* No station, so we are in a purchase list */
571 ctype = CT_PURCHASE;
572 } else if (Station::IsExpected(this->station_scope.st)) {
573 const Station *st = Station::From(this->station_scope.st);
574 /* Pick the first cargo that we have waiting */
575 for (const CargoSpec *cs : CargoSpec::Iterate()) {
576 if (this->station_scope.statspec->grf_prop.spritegroup[cs->Index()] != nullptr &&
577 st->goods[cs->Index()].cargo.TotalCount() > 0) {
578 ctype = cs->Index();
579 break;
580 }
581 }
582 }
583
584 if (this->station_scope.statspec->grf_prop.spritegroup[ctype] == nullptr) {
585 ctype = CT_DEFAULT;
586 }
587
588 /* Remember the cargo type we've picked */
589 this->station_scope.cargo_type = ctype;
590 this->root_spritegroup = this->station_scope.statspec->grf_prop.spritegroup[this->station_scope.cargo_type];
591 }
592
593 StationResolverObject::~StationResolverObject()
594 {
595 delete this->town_scope;
596 }
597
606 SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32 var10)
607 {
608 StationResolverObject object(statspec, st, tile, CBID_NO_CALLBACK, var10);
609 const SpriteGroup *group = object.Resolve();
610 if (group == nullptr || group->type != SGT_RESULT) return 0;
611 return group->GetResult() - 0x42D;
612 }
613
623 SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint layout, uint edge_info)
624 {
625 /* callback_param1 == 2 means we are resolving the foundation sprites. */
626 StationResolverObject object(statspec, st, tile, CBID_NO_CALLBACK, 2, layout | (edge_info << 16));
627
628 const SpriteGroup *group = object.Resolve();
629 if (group == nullptr || group->type != SGT_RESULT) return 0;
630
631 /* Note: SpriteGroup::Resolve zeroes all registers, so register 0x100 is initialised to 0. (compatibility) */
632 return group->GetResult() + GetRegister(0x100);
633 }
634
635
636 uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile)
637 {
638 StationResolverObject object(statspec, st, tile, callback, param1, param2);
639 return object.ResolveCallback();
640 }
641
652 CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_tile, const StationSpec *statspec, Axis axis, byte plat_len, byte numtracks)
653 {
654 TileIndexDiff diff = cur_tile - north_tile;
655 Slope slope = GetTileSlope(cur_tile);
656
657 StationResolverObject object(statspec, nullptr, cur_tile, CBID_STATION_LAND_SLOPE_CHECK,
658 (slope << 4) | (slope ^ (axis == AXIS_Y && HasBit(slope, CORNER_W) != HasBit(slope, CORNER_E) ? SLOPE_EW : 0)),
659 (numtracks << 24) | (plat_len << 16) | (axis == AXIS_Y ? TileX(diff) << 8 | TileY(diff) : TileY(diff) << 8 | TileX(diff)));
660 object.station_scope.axis = axis;
661
662 uint16 cb_res = object.ResolveCallback();
663
664 /* Failed callback means success. */
665 if (cb_res == CALLBACK_FAILED) return CommandCost();
666
667 /* The meaning of bit 10 is inverted for a grf version < 8. */
668 if (statspec->grf_prop.grffile->grf_version < 8) ToggleBit(cb_res, 10);
669 return GetErrorMessageFromLocationCallbackResult(cb_res, statspec->grf_prop.grffile, STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
670 }
671
672
680 int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec)
681 {
682 uint i;
683
684 if (statspec == nullptr || st == nullptr) return 0;
685
686 for (i = 1; i < st->num_specs && i < NUM_STATIONSSPECS_PER_STATION; i++) {
687 if (st->speclist[i].spec == nullptr && st->speclist[i].grfid == 0) break;
688 }
689
690 if (i == NUM_STATIONSSPECS_PER_STATION) {
691 /* As final effort when the spec list is already full...
692 * try to find the same spec and return that one. This might
693 * result in slightly "wrong" (as per specs) looking stations,
694 * but it's fairly unlikely that one reaches the limit anyways.
695 */
696 for (i = 1; i < st->num_specs && i < NUM_STATIONSSPECS_PER_STATION; i++) {
697 if (st->speclist[i].spec == statspec) return i;
698 }
699
700 return -1;
701 }
702
703 if (exec) {
704 if (i >= st->num_specs) {
705 st->num_specs = i + 1;
706 st->speclist = ReallocT(st->speclist, st->num_specs);
707
708 if (st->num_specs == 2) {
709 /* Initial allocation */
710 st->speclist[0].spec = nullptr;
711 st->speclist[0].grfid = 0;
712 st->speclist[0].localidx = 0;
713 }
714 }
715
716 st->speclist[i].spec = statspec;
717 st->speclist[i].grfid = statspec->grf_prop.grffile->grfid;
718 st->speclist[i].localidx = statspec->grf_prop.local_id;
719
720 StationUpdateCachedTriggers(st);
721 }
722
723 return i;
724 }
725
726
733 void DeallocateSpecFromStation(BaseStation *st, byte specindex)
734 {
735 /* specindex of 0 (default) is never freeable */
736 if (specindex == 0) return;
737
738 ETileArea area = ETileArea(st, INVALID_TILE, TA_WHOLE);
739 /* Check all tiles over the station to check if the specindex is still in use */
740 for (TileIndex tile : area) {
741 if (st->TileBelongsToRailStation(tile) && GetCustomStationSpecIndex(tile) == specindex) {
742 return;
743 }
744 }
745
746 /* This specindex is no longer in use, so deallocate it */
747 st->speclist[specindex].spec = nullptr;
748 st->speclist[specindex].grfid = 0;
749 st->speclist[specindex].localidx = 0;
750
751 /* If this was the highest spec index, reallocate */
752 if (specindex == st->num_specs - 1) {
753 for (; st->speclist[st->num_specs - 1].grfid == 0 && st->num_specs > 1; st->num_specs--) {}
754
755 if (st->num_specs > 1) {
756 st->speclist = ReallocT(st->speclist, st->num_specs);
757 } else {
758 free(st->speclist);
759 st->num_specs = 0;
760 st->speclist = nullptr;
761 st->cached_anim_triggers = 0;
762 st->cached_cargo_triggers = 0;
763 return;
764 }
765 }
766
767 StationUpdateCachedTriggers(st);
768 }
769
780 bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station)
781 {
782 const DrawTileSprites *sprites = nullptr;
783 const RailtypeInfo *rti = GetRailTypeInfo(railtype);
784 PaletteID palette = COMPANY_SPRITE_COLOUR(_local_company);
785 uint tile = 2;
786
787 const StationSpec *statspec = StationClass::Get(sclass)->GetSpec(station);
788 if (statspec == nullptr) return false;
789
790 if (HasBit(statspec->callback_mask, CBM_STATION_SPRITE_LAYOUT)) {
791 uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0x2110000, 0, statspec, nullptr, INVALID_TILE);
792 if (callback != CALLBACK_FAILED) tile = callback;
793 }
794
795 uint32 total_offset = rti->GetRailtypeSpriteOffset();
796 uint32 relocation = 0;
797 uint32 ground_relocation = 0;
798 const NewGRFSpriteLayout *layout = nullptr;
799 DrawTileSprites tmp_rail_layout;
800
801 if (statspec->renderdata.empty()) {
802 sprites = GetStationTileLayout(STATION_RAIL, tile + axis);
803 } else {
804 layout = &statspec->renderdata[(tile < statspec->renderdata.size()) ? tile + axis : (uint)axis];
805 if (!layout->NeedsPreprocessing()) {
806 sprites = layout;
807 layout = nullptr;
808 }
809 }
810
811 if (layout != nullptr) {
812 /* Sprite layout which needs preprocessing */
813 bool separate_ground = HasBit(statspec->flags, SSF_SEPARATE_GROUND);
814 uint32 var10_values = layout->PrepareLayout(total_offset, rti->fallback_railtype, 0, 0, separate_ground);
815 for (uint8 var10 : SetBitIterator(var10_values)) {
816 uint32 var10_relocation = GetCustomStationRelocation(statspec, nullptr, INVALID_TILE, var10);
817 layout->ProcessRegisters(var10, var10_relocation, separate_ground);
818 }
819
820 tmp_rail_layout.seq = layout->GetLayout(&tmp_rail_layout.ground);
821 sprites = &tmp_rail_layout;
822 total_offset = 0;
823 } else {
824 /* Simple sprite layout */
825 ground_relocation = relocation = GetCustomStationRelocation(statspec, nullptr, INVALID_TILE, 0);
826 if (HasBit(sprites->ground.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE)) {
827 ground_relocation = GetCustomStationRelocation(statspec, nullptr, INVALID_TILE, 1);
828 }
829 ground_relocation += rti->fallback_railtype;
830 }
831
832 SpriteID image = sprites->ground.sprite;
833 PaletteID pal = sprites->ground.pal;
834 RailTrackOffset overlay_offset;
835 if (rti->UsesOverlay() && SplitGroundSpriteForOverlay(nullptr, &image, &overlay_offset)) {
836 SpriteID ground = GetCustomRailSprite(rti, INVALID_TILE, RTSG_GROUND);
837 DrawSprite(image, PAL_NONE, x, y);
838 DrawSprite(ground + overlay_offset, PAL_NONE, x, y);
839 } else {
840 image += HasBit(image, SPRITE_MODIFIER_CUSTOM_SPRITE) ? ground_relocation : total_offset;
841 if (HasBit(pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) pal += ground_relocation;
842 DrawSprite(image, GroundSpritePaletteTransform(image, pal, palette), x, y);
843 }
844
845 DrawRailTileSeqInGUI(x, y, sprites, total_offset, relocation, palette);
846
847 return true;
848 }
849
850
851 const StationSpec *GetStationSpec(TileIndex t)
852 {
853 if (!IsCustomStationSpecIndex(t)) return nullptr;
854
855 const BaseStation *st = BaseStation::GetByTile(t);
856 uint specindex = GetCustomStationSpecIndex(t);
857 return specindex < st->num_specs ? st->speclist[specindex].spec : nullptr;
858 }
859
860
867 bool IsStationTileBlocked(TileIndex tile)
868 {
869 const StationSpec *statspec = GetStationSpec(tile);
870
871 return statspec != nullptr && HasBit(statspec->blocked, GetStationGfx(tile));
872 }
873
880 bool CanStationTileHavePylons(TileIndex tile)
881 {
882 const StationSpec *statspec = GetStationSpec(tile);
883 uint gfx = GetStationGfx(tile);
884 /* Default stations do not draw pylons under roofs (gfx >= 4) */
885 return statspec != nullptr ? HasBit(statspec->pylons, gfx) : gfx < 4;
886 }
887
894 bool CanStationTileHaveWires(TileIndex tile)
895 {
896 const StationSpec *statspec = GetStationSpec(tile);
897 return statspec == nullptr || !HasBit(statspec->wires, GetStationGfx(tile));
898 }
899
901 uint16 GetAnimStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, int extra_data)
902 {
903 return GetStationCallback(callback, param1, param2, statspec, st, tile);
904 }
905
907 struct StationAnimationBase : public AnimationBase<StationAnimationBase, StationSpec, BaseStation, int, GetAnimStationCallback> {
908 static const CallbackID cb_animation_speed = CBID_STATION_ANIMATION_SPEED;
909 static const CallbackID cb_animation_next_frame = CBID_STATION_ANIM_NEXT_FRAME;
910
911 static const StationCallbackMask cbm_animation_speed = CBM_STATION_ANIMATION_SPEED;
912 static const StationCallbackMask cbm_animation_next_frame = CBM_STATION_ANIMATION_NEXT_FRAME;
913 };
914
915 void AnimateStationTile(TileIndex tile)
916 {
917 const StationSpec *ss = GetStationSpec(tile);
918 if (ss == nullptr) return;
919
920 StationAnimationBase::AnimateTile(ss, BaseStation::GetByTile(tile), tile, HasBit(ss->flags, SSF_CB141_RANDOM_BITS));
921 }
922
923 void TriggerStationAnimation(BaseStation *st, TileIndex trigger_tile, StationAnimationTrigger trigger, CargoID cargo_type)
924 {
925 /* List of coverage areas for each animation trigger */
926 static const TriggerArea tas[] = {
927 TA_TILE, TA_WHOLE, TA_WHOLE, TA_PLATFORM, TA_PLATFORM, TA_PLATFORM, TA_WHOLE
928 };
929
930 /* Get Station if it wasn't supplied */
931 if (st == nullptr) st = BaseStation::GetByTile(trigger_tile);
932
933 /* Check the cached animation trigger bitmask to see if we need
934 * to bother with any further processing. */
935 if (!HasBit(st->cached_anim_triggers, trigger)) return;
936
937 uint16 random_bits = Random();
938 ETileArea area = ETileArea(st, trigger_tile, tas[trigger]);
939
940 /* Check all tiles over the station to check if the specindex is still in use */
941 for (TileIndex tile : area) {
942 if (st->TileBelongsToRailStation(tile)) {
943 const StationSpec *ss = GetStationSpec(tile);
944 if (ss != nullptr && HasBit(ss->animation.triggers, trigger)) {
945 CargoID cargo;
946 if (cargo_type == CT_INVALID) {
947 cargo = CT_INVALID;
948 } else {
949 cargo = ss->grf_prop.grffile->cargo_map[cargo_type];
950 }
951 StationAnimationBase::ChangeAnimationFrame(CBID_STATION_ANIM_START_STOP, ss, st, tile, (random_bits << 16) | Random(), (uint8)trigger | (cargo << 8));
952 }
953 }
954 }
955 }
956
964 void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRandomTrigger trigger, CargoID cargo_type)
965 {
966 /* List of coverage areas for each animation trigger */
967 static const TriggerArea tas[] = {
968 TA_WHOLE, TA_WHOLE, TA_PLATFORM, TA_PLATFORM, TA_PLATFORM, TA_PLATFORM
969 };
970
971 /* Get Station if it wasn't supplied */
972 if (st == nullptr) st = Station::GetByTile(trigger_tile);
973
974 /* Check the cached cargo trigger bitmask to see if we need
975 * to bother with any further processing. */
976 if (st->cached_cargo_triggers == 0) return;
977 if (cargo_type != CT_INVALID && !HasBit(st->cached_cargo_triggers, cargo_type)) return;
978
979 uint32 whole_reseed = 0;
980 ETileArea area = ETileArea(st, trigger_tile, tas[trigger]);
981
982 CargoTypes empty_mask = 0;
983 if (trigger == SRT_CARGO_TAKEN) {
984 /* Create a bitmask of completely empty cargo types to be matched */
985 for (CargoID i = 0; i < NUM_CARGO; i++) {
986 if (st->goods[i].cargo.TotalCount() == 0) {
987 SetBit(empty_mask, i);
988 }
989 }
990 }
991
992 /* Store triggers now for var 5F */
993 SetBit(st->waiting_triggers, trigger);
994 uint32 used_triggers = 0;
995
996 /* Check all tiles over the station to check if the specindex is still in use */
997 for (TileIndex tile : area) {
998 if (st->TileBelongsToRailStation(tile)) {
999 const StationSpec *ss = GetStationSpec(tile);
1000 if (ss == nullptr) continue;
1001
1002 /* Cargo taken "will only be triggered if all of those
1003 * cargo types have no more cargo waiting." */
1004 if (trigger == SRT_CARGO_TAKEN) {
1005 if ((ss->cargo_triggers & ~empty_mask) != 0) continue;
1006 }
1007
1008 if (cargo_type == CT_INVALID || HasBit(ss->cargo_triggers, cargo_type)) {
1009 StationResolverObject object(ss, st, tile, CBID_RANDOM_TRIGGER, 0);
1010 object.waiting_triggers = st->waiting_triggers;
1011
1012 const SpriteGroup *group = object.Resolve();
1013 if (group == nullptr) continue;
1014
1015 used_triggers |= object.used_triggers;
1016
1017 uint32 reseed = object.GetReseedSum();
1018 if (reseed != 0) {
1019 whole_reseed |= reseed;
1020 reseed >>= 16;
1021
1022 /* Set individual tile random bits */
1023 uint8 random_bits = GetStationTileRandomBits(tile);
1024 random_bits &= ~reseed;
1025 random_bits |= Random() & reseed;
1026 SetStationTileRandomBits(tile, random_bits);
1027
1028 MarkTileDirtyByTile(tile);
1029 }
1030 }
1031 }
1032 }
1033
1034 /* Update whole station random bits */
1035 st->waiting_triggers &= ~used_triggers;
1036 if ((whole_reseed & 0xFFFF) != 0) {
1037 st->random_bits &= ~whole_reseed;
1038 st->random_bits |= Random() & whole_reseed;
1039 }
1040 }
1041
1046 void StationUpdateCachedTriggers(BaseStation *st)
1047 {
1048 st->cached_anim_triggers = 0;
1049 st->cached_cargo_triggers = 0;
1050
1051 /* Combine animation trigger bitmask for all station specs
1052 * of this station. */
1053 for (uint i = 0; i < st->num_specs; i++) {
1054 const StationSpec *ss = st->speclist[i].spec;
1055 if (ss != nullptr) {
1056 st->cached_anim_triggers |= ss->animation.triggers;
1057 st->cached_cargo_triggers |= ss->cargo_triggers;
1058 }
1059 }
1060 }
1061
DrawRailTileSeqInGUI
static void DrawRailTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette)
Draw tile sprite sequence in GUI with railroad specifics.
Definition: sprite.h:99
AllocateSpecToStation
int AllocateSpecToStation(const StationSpec *statspec, BaseStation *st, bool exec)
Allocate a StationSpec to a Station.
Definition: newgrf_station.cpp:680
BaseStation::facilities
StationFacility facilities
The facilities that this station has.
Definition: base_station_base.h:63
DIAGDIR_SE
@ DIAGDIR_SE
Southeast.
Definition: direction_type.h:80
SplitGroundSpriteForOverlay
bool SplitGroundSpriteForOverlay(const TileInfo *ti, SpriteID *ground, RailTrackOffset *overlay_offset)
Check whether a sprite is a track sprite, which can be replaced by a non-track ground sprite and a ra...
Definition: station_cmd.cpp:2765
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
TILE_ADD
#define TILE_ADD(x, y)
Adds to tiles together.
Definition: map_func.h:244
DIR_SW
@ DIR_SW
Southwest.
Definition: direction_type.h:31
StationScopeResolver::cargo_type
CargoID cargo_type
Type of cargo of the station.
Definition: newgrf_station.h:28
Station::goods
GoodsEntry goods[NUM_CARGO]
Goods at this station.
Definition: station_base.h:476
TRACK_BIT_NONE
@ TRACK_BIT_NONE
No track.
Definition: track_type.h:39
newgrf_station.h
StationSpec::flags
byte flags
Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size.
Definition: newgrf_station.h:160
TileOffsByDiagDir
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition: map_func.h:341
Direction
Direction
Defines the 8 directions on the map.
Definition: direction_type.h:24
StationSpec::renderdata
std::vector< NewGRFSpriteLayout > renderdata
Number of tile layouts.
Definition: newgrf_station.h:148
GB
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
CargoList::DaysInTransit
uint DaysInTransit() const
Returns average number of days in transit for a cargo entity.
Definition: cargopacket.h:256
NewGRFSpriteLayout::PrepareLayout
uint32 PrepareLayout(uint32 orig_offset, uint32 newgrf_ground_offset, uint32 newgrf_offset, uint constr_stage, bool separate_ground) const
Prepares a sprite layout before resolving action-1-2-3 chains.
Definition: newgrf_commons.cpp:660
DIR_SE
@ DIR_SE
Southeast.
Definition: direction_type.h:29
ClosestTownFromTile
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
Definition: town_cmd.cpp:3592
BaseStation::GetTileArea
virtual void GetTileArea(TileArea *ta, StationType type) const =0
Get the tile area for a given station type.
BaseStation::waiting_triggers
byte waiting_triggers
Waiting triggers (NewGRF) for this station.
Definition: base_station_base.h:71
GetCustomStationRelocation
SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32 var10)
Resolve sprites for drawing a station tile.
Definition: newgrf_station.cpp:606
StationRandomTrigger
StationRandomTrigger
Randomisation triggers for stations.
Definition: newgrf_station.h:103
TRANSPORT_RAIL
@ TRANSPORT_RAIL
Transport by train.
Definition: transport_type.h:27
tunnelbridge_map.h
StationScopeResolver::GetTriggers
uint32 GetTriggers() const override
Get the triggers.
Definition: newgrf_station.cpp:230
BaseStation::town
Town * town
The town this station is associated with.
Definition: base_station_base.h:61
Station
Station data structure.
Definition: station_base.h:447
BaseStation::GetByTile
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
Definition: base_station_base.h:155
StationSpecList
Definition: base_station_base.h:21
DIR_NW
@ DIR_NW
Northwest.
Definition: direction_type.h:33
SSF_DIV_BY_STATION_SIZE
@ SSF_DIV_BY_STATION_SIZE
Divide cargo amount by station size.
Definition: newgrf_station.h:96
AnimationBase< StationAnimationBase, StationSpec, BaseStation, int, GetAnimStationCallback >::ChangeAnimationFrame
static void ChangeAnimationFrame(CallbackID cb, const StationSpec *spec, BaseStation *obj, TileIndex tile, uint32 random_bits, uint32 trigger, int extra_data=0)
Check a callback to determine what the next animation step is and execute that step.
Definition: newgrf_animation_base.h:117
IsCustomStationSpecIndex
static bool IsCustomStationSpecIndex(TileIndex t)
Is there a custom rail station spec on this tile?
Definition: station_map.h:469
Waypoint::GetNewGRFVariable
uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const override
Helper function to get a NewGRF variable that isn't implemented by the base class.
Definition: newgrf_station.cpp:463
StationSpecList::localidx
uint8 localidx
Station ID within GRF of station.
Definition: base_station_base.h:24
INSTANTIATE_NEWGRF_CLASS_METHODS
#define INSTANTIATE_NEWGRF_CLASS_METHODS(name, Tspec, Tid, Tmax)
Force instantiation of the methods so we don't get linker errors.
Definition: newgrf_class_func.h:216
PalSpriteID::sprite
SpriteID sprite
The 'real' sprite.
Definition: gfx_type.h:23
ResolverObject
Interface for SpriteGroup-s to access the gamestate.
Definition: newgrf_spritegroup.h:307
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
NewGRFSpriteLayout::ProcessRegisters
void ProcessRegisters(uint8 resolved_var10, uint32 resolved_sprite, bool separate_ground) const
Evaluates the register modifiers and integrates them into the preprocessed sprite layout.
Definition: newgrf_commons.cpp:731
RailtypeInfo
This struct contains all the info that is needed to draw and construct tracks.
Definition: rail.h:124
ResolverObject::grffile
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
Definition: newgrf_spritegroup.h:335
IsCompatibleTrainStationTile
static bool IsCompatibleTrainStationTile(TileIndex test_tile, TileIndex station_tile)
Check if a tile is a valid continuation to a railstation tile.
Definition: station_map.h:378
valid
uint8 valid
Bits indicating what variable is valid (for each bit, 0 is invalid, 1 is valid).
Definition: newgrf_station.cpp:248
newgrf_animation_base.h
StationScopeResolver::statspec
const struct StationSpec * statspec
Station (type) specification.
Definition: newgrf_station.h:27
GetAnimStationCallback
uint16 GetAnimStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, int extra_data)
Wrapper for animation control, see GetStationCallback.
Definition: newgrf_station.cpp:901
CargoSpec::Iterate
static IterateWrapper Iterate(size_t from=0)
Returns an iterable ensemble of all valid CargoSpec.
Definition: cargotype.h:168
GetRegister
static uint32 GetRegister(uint i)
Gets the value of a so-called newgrf "register".
Definition: newgrf_spritegroup.h:29
CBM_STATION_ANIMATION_NEXT_FRAME
@ CBM_STATION_ANIMATION_NEXT_FRAME
Use a custom next frame callback.
Definition: newgrf_callbacks.h:305
CargoSpec
Specification of a cargo type.
Definition: cargotype.h:57
AnimationBase< StationAnimationBase, StationSpec, BaseStation, int, GetAnimStationCallback >::AnimateTile
static void AnimateTile(const StationSpec *spec, BaseStation *obj, TileIndex tile, bool random_animation, int extra_data=0)
Animate a single tile.
Definition: newgrf_animation_base.h:38
town.h
TileY
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition: map_func.h:215
newgrf_class_func.h
DIAGDIR_NW
@ DIAGDIR_NW
Northwest.
Definition: direction_type.h:82
DIR_W
@ DIR_W
West.
Definition: direction_type.h:32
CallbackID
CallbackID
List of implemented NewGRF callbacks.
Definition: newgrf_callbacks.h:20
SLOPE_EW
@ SLOPE_EW
east and west corner are raised
Definition: slope_type.h:59
RailtypeInfo::fallback_railtype
byte fallback_railtype
Original railtype number to use when drawing non-newgrf railtypes, or when drawing stations.
Definition: rail.h:198
StationResolverObject::station_scope
StationScopeResolver station_scope
The station scope resolver.
Definition: newgrf_station.h:51
StationResolverObject::GetTown
TownScopeResolver * GetTown()
Get the town scope associated with a station, if it exists.
Definition: newgrf_station.cpp:256
DeallocateSpecFromStation
void DeallocateSpecFromStation(BaseStation *st, byte specindex)
Deallocate a StationSpec from a Station.
Definition: newgrf_station.cpp:733
BaseStation::owner
Owner owner
The owner of this station.
Definition: base_station_base.h:62
DIR_N
@ DIR_N
North.
Definition: direction_type.h:26
NUM_STATIONSSPECS_PER_STATION
static const uint NUM_STATIONSSPECS_PER_STATION
Maximum number of parts per station.
Definition: newgrf_station.cpp:51
GoodsEntry::status
byte status
Status of this cargo, see GoodsEntryStatus.
Definition: station_base.h:223
StationCargoList::TotalCount
uint TotalCount() const
Returns total count of cargo at the station, including cargo which is already reserved for loading.
Definition: cargopacket.h:527
BaseStation::num_specs
uint8 num_specs
Number of specs in the speclist.
Definition: base_station_base.h:65
TileX
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition: map_func.h:205
BaseStation::TileBelongsToRailStation
virtual bool TileBelongsToRailStation(TileIndex tile) const =0
Check whether a specific tile belongs to this station.
BaseStation::string_id
StringID string_id
Default name (town area) of station.
Definition: base_station_base.h:58
BaseStation::cached_anim_triggers
uint8 cached_anim_triggers
NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen.
Definition: base_station_base.h:72
GetTileTrackStatus
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
Definition: landscape.cpp:590
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
BaseStation::cached_cargo_triggers
CargoTypes cached_cargo_triggers
NOSAVE: Combined cargo trigger bitmask.
Definition: base_station_base.h:73
SSF_SEPARATE_GROUND
@ SSF_SEPARATE_GROUND
Use different sprite set for ground sprites.
Definition: newgrf_station.h:95
SSF_CB141_RANDOM_BITS
@ SSF_CB141_RANDOM_BITS
Callback 141 needs random bits.
Definition: newgrf_station.h:97
StationSpecList::grfid
uint32 grfid
GRF ID of this custom station.
Definition: base_station_base.h:23
GoodsEntry::cargo
StationCargoList cargo
The cargo packets of cargo waiting in this station.
Definition: station_base.h:252
DrawTileSprites::ground
PalSpriteID ground
Palette and sprite for the ground.
Definition: sprite.h:59
GetRailTypeInfo
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition: rail.h:304
NewGRFClass::IsUIAvailable
bool IsUIAvailable(uint index) const
Check whether the spec will be available to the user at some point in time.
Definition: newgrf_airport.cpp:79
StationCargoList::Source
StationID Source() const
Returns source of the first cargo packet in this list.
Definition: cargopacket.h:498
RealSpriteGroup::loading
std::vector< const SpriteGroup * > loading
List of loading groups (can be SpriteIDs or Callback results)
Definition: newgrf_spritegroup.h:90
GetPlatformInfo
uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred)
Evaluate a tile's position within a station, and return the result in a bit-stuffed format.
Definition: newgrf_station.cpp:105
DIAGDIR_SW
@ DIAGDIR_SW
Southwest.
Definition: direction_type.h:81
GetAnimationFrame
static byte GetAnimationFrame(TileIndex t)
Get the current animation frame.
Definition: tile_map.h:250
StationCallbackMask
StationCallbackMask
Callback masks for stations.
Definition: newgrf_callbacks.h:302
AXIS_Y
@ AXIS_Y
The y axis.
Definition: direction_type.h:125
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
STAT_CLASS_WAYP
@ STAT_CLASS_WAYP
Waypoint class.
Definition: newgrf_station.h:86
CommandCost
Common return value for all commands.
Definition: command_type.h:23
GetCustomStationSpecIndex
static uint GetCustomStationSpecIndex(TileIndex t)
Get the custom station spec for this tile.
Definition: station_map.h:493
CBID_STATION_LAND_SLOPE_CHECK
@ CBID_STATION_LAND_SLOPE_CHECK
Callback done for each tile of a station to check the slope.
Definition: newgrf_callbacks.h:212
_svc
static struct @30 _svc
Station variable cache This caches 'expensive' station variable lookups which iterate over several ti...
SetBitIterator
Iterable ensemble of each set bit in a value.
Definition: bitmath_func.hpp:329
_date
Date _date
Current date in days (day counter)
Definition: date.cpp:28
HasStationRail
static bool HasStationRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
Definition: station_map.h:135
GoodsEntry::GES_EVER_ACCEPTED
@ GES_EVER_ACCEPTED
Set when a vehicle ever delivered cargo to the station for final delivery.
Definition: station_base.h:190
BaseStation::train_station
TileArea train_station
Tile area the train 'station' part covers.
Definition: base_station_base.h:75
DIR_E
@ DIR_E
East.
Definition: direction_type.h:28
CBM_STATION_ANIMATION_SPEED
@ CBM_STATION_ANIMATION_SPEED
Customize the animation speed of the station.
Definition: newgrf_callbacks.h:306
BaseStation::random_bits
uint16 random_bits
Random bits assigned to this station.
Definition: base_station_base.h:70
StationResolverObject::town_scope
TownScopeResolver * town_scope
The town scope resolver (created on the first call).
Definition: newgrf_station.h:52
roadstop_base.h
TileIndexDiff
int32 TileIndexDiff
An offset value between to tiles.
Definition: map_func.h:154
GoodsEntry::HasRating
bool HasRating() const
Does this cargo have a rating at this station?
Definition: station_base.h:270
StationSpec::pylons
byte pylons
Bitmask of base tiles (0 - 7) which should contain elrail pylons.
Definition: newgrf_station.h:162
TrackStatusToTrackBits
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
Definition: track_func.h:362
HVOT_WAYPOINT
@ HVOT_WAYPOINT
Station is a waypoint (NewGRF only!)
Definition: station_type.h:70
CBID_NO_CALLBACK
@ CBID_NO_CALLBACK
Set when using the callback resolve system, but not to resolve a callback.
Definition: newgrf_callbacks.h:22
GoodsEntry::last_speed
byte last_speed
Maximum speed (up to 255) of the last vehicle that tried to load this cargo.
Definition: station_base.h:243
ResolverObject::root_spritegroup
const SpriteGroup * root_spritegroup
Root SpriteGroup to use for resolving.
Definition: newgrf_spritegroup.h:336
GoodsEntry::GES_ACCEPTED_BIGTICK
@ GES_ACCEPTED_BIGTICK
Set when cargo was delivered for final delivery during the current STATION_ACCEPTANCE_TICKS interval.
Definition: station_base.h:208
SB
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
Definition: bitmath_func.hpp:58
SpecializedStation< Station, false >::IsExpected
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
Definition: base_station_base.h:200
OrthogonalTileArea::w
uint16 w
The width of the area.
Definition: tilearea_type.h:20
Station::airport
Airport airport
Tile area the airport covers.
Definition: station_base.h:461
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:18
DIR_NE
@ DIR_NE
Northeast.
Definition: direction_type.h:27
NewGRFClass
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:19
Station::TileBelongsToRailStation
bool TileBelongsToRailStation(TileIndex tile) const override
Check whether a specific tile belongs to this station.
Definition: station_base.h:511
GetErrorMessageFromLocationCallbackResult
CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, const GRFFile *grffile, StringID default_error)
Get the error message from a shape/location/slope check callback result.
Definition: newgrf_commons.cpp:480
AirportSpec::ttd_airport_type
TTDPAirportType ttd_airport_type
ttdpatch airport type (Small/Large/Helipad/Oilrig)
Definition: newgrf_airport.h:112
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
TileOffsByDir
static TileIndexDiff TileOffsByDir(Direction dir)
Convert a Direction to a TileIndexDiff.
Definition: map_func.h:355
NewGRFSpriteLayout
NewGRF supplied spritelayout.
Definition: newgrf_commons.h:113
HasStationTileRail
static bool HasStationTileRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
Definition: station_map.h:146
DiagdirReachesTracks
static TrackBits DiagdirReachesTracks(DiagDirection diagdir)
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction.
Definition: track_func.h:572
safeguards.h
NewGRFSpriteLayout::NeedsPreprocessing
bool NeedsPreprocessing() const
Tests whether this spritelayout needs preprocessing by PrepareLayout() and ProcessRegisters(),...
Definition: newgrf_commons.h:150
Airport::flags
uint64 flags
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
Definition: station_base.h:305
SetStationTileRandomBits
static void SetStationTileRandomBits(TileIndex t, byte random_bits)
Set the random bits for a station tile.
Definition: station_map.h:505
GetTileSlope
Slope GetTileSlope(TileIndex tile, int *h)
Return the slope of a given tile inside the map.
Definition: tile_map.cpp:59
CanStationTileHaveWires
bool CanStationTileHaveWires(TileIndex tile)
Check if a rail station tile shall have wires when electrified.
Definition: newgrf_station.cpp:894
DIR_S
@ DIR_S
South.
Definition: direction_type.h:30
SPRITE_MODIFIER_CUSTOM_SPRITE
@ SPRITE_MODIFIER_CUSTOM_SPRITE
Set when a sprite originates from an Action 1.
Definition: sprites.h:1537
HasStationReservation
static bool HasStationReservation(TileIndex t)
Get the reservation state of the rail station.
Definition: station_map.h:393
OrthogonalTileArea::end
OrthogonalTileIterator end() const
Returns an iterator to the end of the tile area.
Definition: tilearea.cpp:162
DrawTileSprites
Ground palette sprite of a tile, together with its sprite layout.
Definition: sprite.h:58
STAT_CLASS_MAX
@ STAT_CLASS_MAX
Maximum number of classes.
Definition: newgrf_station.h:87
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:1042
MP_TUNNELBRIDGE
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
Definition: tile_type.h:55
RTSG_GROUND
@ RTSG_GROUND
Main group of ground images.
Definition: rail.h:49
TownScopeResolver
Scope resolver for a town.
Definition: newgrf_town.h:22
GoodsEntry::rating
byte rating
Station rating for this cargo.
Definition: station_base.h:232
GetNearbyTileInformation
uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8)
Common part of station var 0x67, house var 0x62, indtile var 0x60, industry var 0x62.
Definition: newgrf_commons.cpp:446
Slope
Slope
Enumeration for the slope-type.
Definition: slope_type.h:48
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:77
SpecializedStation< Station, false >::From
static Station * From(BaseStation *st)
Converts a BaseStation to SpecializedStation with type checking.
Definition: base_station_base.h:248
CBID_STATION_ANIM_NEXT_FRAME
@ CBID_STATION_ANIM_NEXT_FRAME
Called to determine station tile next animation frame.
Definition: newgrf_callbacks.h:188
IsRailStationTile
static bool IsRailStationTile(TileIndex t)
Is this tile a station tile and a rail station?
Definition: station_map.h:102
stdafx.h
StationResolverObject::GetDebugID
uint32 GetDebugID() const override
Get an identifier for the item being resolved.
Definition: newgrf_station.cpp:545
Station::truck_stops
RoadStop * truck_stops
All the truck stops.
Definition: station_base.h:458
StationResolverObject::ResolveReal
const SpriteGroup * ResolveReal(const RealSpriteGroup *group) const override
Get the real sprites of the grf.
Definition: newgrf_station.cpp:495
NewGRFClass::InsertDefaults
static void InsertDefaults()
Initialise the defaults.
Definition: newgrf_airport.cpp:70
AxisToDiagDir
static DiagDirection AxisToDiagDir(Axis a)
Converts an Axis to a DiagDirection.
Definition: direction_func.h:232
IsTileType
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
Definition: tile_map.h:150
StationScopeResolver::axis
Axis axis
Station axis, used only for the slope check callback.
Definition: newgrf_station.h:29
RealSpriteGroup::loaded
std::vector< const SpriteGroup * > loaded
List of loaded groups (can be SpriteIDs or Callback results)
Definition: newgrf_spritegroup.h:89
GetTunnelBridgeDirection
static DiagDirection GetTunnelBridgeDirection(TileIndex t)
Get the direction pointing to the other end.
Definition: tunnelbridge_map.h:26
GroundSpritePaletteTransform
static PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
Definition: sprite.h:168
OrthogonalTileArea::h
uint16 h
The height of the area.
Definition: tilearea_type.h:21
newgrf_spritegroup.h
newgrf_town.h
GrfSpecFeature
GrfSpecFeature
Definition: newgrf.h:66
SpriteGroup::Resolve
virtual const SpriteGroup * Resolve(ResolverObject &object) const
Base sprite group resolver.
Definition: newgrf_spritegroup.h:61
IsStationTileBlocked
bool IsStationTileBlocked(TileIndex tile)
Check whether a rail station tile is NOT traversable.
Definition: newgrf_station.cpp:867
SRT_CARGO_TAKEN
@ SRT_CARGO_TAKEN
Trigger station when cargo is completely taken.
Definition: newgrf_station.h:105
GoodsEntry::GES_CURRENT_MONTH
@ GES_CURRENT_MONTH
Set when cargo was delivered for final delivery this month.
Definition: station_base.h:202
CALLBACK_FAILED
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Definition: newgrf_callbacks.h:404
GetCustomRailSprite
SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
Definition: newgrf_railtype.cpp:95
GoodsEntry
Stores station stats for a single cargo.
Definition: station_base.h:167
_current_company
CompanyID _current_company
Company currently doing an action.
Definition: company_cmd.cpp:47
station_base.h
newgrf_sound.h
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:77
GRFFilePropsBase::spritegroup
const struct SpriteGroup * spritegroup[Tcnt]
pointer to the different sprites of the entity
Definition: newgrf_commons.h:321
StationSpec
Station specification.
Definition: newgrf_station.h:113
GoodsEntry::last_age
byte last_age
Age in years (up to 255) of the last vehicle that tried to load this cargo.
Definition: station_base.h:249
PerformStationTileSlopeCheck
CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_tile, const StationSpec *statspec, Axis axis, byte plat_len, byte numtracks)
Check the slope of a tile of a new station.
Definition: newgrf_station.cpp:652
GetStationGfx
static StationGfx GetStationGfx(TileIndex t)
Get the station graphics of this tile.
Definition: station_map.h:68
GetRailStationAxis
static Axis GetRailStationAxis(TileIndex t)
Get the rail direction of a rail station.
Definition: station_map.h:337
RailTrackOffset
RailTrackOffset
Offsets for sprites within an overlay/underlay set.
Definition: rail.h:67
CBID_STATION_ANIM_START_STOP
@ CBID_STATION_ANIM_START_STOP
Called for periodically starting or stopping the animation.
Definition: newgrf_callbacks.h:185
OrthogonalTileArea::tile
TileIndex tile
The base tile of the area.
Definition: tilearea_type.h:19
PaletteID
uint32 PaletteID
The number of the palette.
Definition: gfx_type.h:18
RealSpriteGroup
Definition: newgrf_spritegroup.h:79
StationAnimationTrigger
StationAnimationTrigger
Animation triggers for station.
Definition: newgrf_animation_type.h:26
MarkTileDirtyByTile
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
Definition: viewport.cpp:1987
TileDiffXY
static TileIndexDiff TileDiffXY(int x, int y)
Calculates an offset for the given coordinate(-offset).
Definition: map_func.h:179
GetRailType
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
Definition: rail_map.h:115
StationScopeResolver::st
struct BaseStation * st
Instance of the station.
Definition: newgrf_station.h:26
MP_STATION
@ MP_STATION
A tile of a station.
Definition: tile_type.h:51
NUM_CARGO
@ NUM_CARGO
Maximal number of cargo types in a game.
Definition: cargo_type.h:65
GoodsEntry::GES_ACCEPTANCE
@ GES_ACCEPTANCE
Set when the station accepts the cargo currently for final deliveries.
Definition: station_base.h:174
SpecializedStation< Station, false >::GetByTile
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
Definition: base_station_base.h:238
GetStationIndex
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
Definition: station_map.h:28
waypoint_base.h
GoodsEntry::time_since_pickup
byte time_since_pickup
Number of rating-intervals (up to 255) since the last vehicle tried to load this cargo.
Definition: station_base.h:230
StationClassID
StationClassID
Definition: newgrf_station.h:83
GetCargoTranslation
CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit)
Translate a GRF-local cargo slot/bitnum into a CargoID.
Definition: newgrf_cargo.cpp:79
GRFFile::cargo_map
uint8 cargo_map[NUM_CARGO]
Inverse cargo translation table (CargoID -> local ID)
Definition: newgrf.h:127
StationScopeResolver::GetRandomBits
uint32 GetRandomBits() const override
Get a few random bits.
Definition: newgrf_station.cpp:224
CBID_STATION_ANIMATION_SPEED
@ CBID_STATION_ANIMATION_SPEED
Called to indicate how long the current animation frame should last.
Definition: newgrf_callbacks.h:191
BaseStation
Base class for all station-ish types.
Definition: base_station_base.h:52
GetStationTileRandomBits
static byte GetStationTileRandomBits(TileIndex t)
Get the random bits of a station tile.
Definition: station_map.h:517
CanStationTileHavePylons
bool CanStationTileHavePylons(TileIndex tile)
Check if a rail station tile shall have pylons when electrified.
Definition: newgrf_station.cpp:880
company_func.h
AnimationInfo::triggers
uint16 triggers
The triggers that trigger animation.
Definition: newgrf_animation_type.h:22
RoadStop::status
byte status
Current status of the Stop,.
Definition: roadstop_base.h:68
ReallocT
static T * ReallocT(T *t_ptr, size_t num_elements)
Simplified reallocation function that allocates the specified number of elements of the given type.
Definition: alloc_func.hpp:111
GetReverseRailTypeTranslation
uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile)
Perform a reverse railtype lookup to get the GRF internal ID.
Definition: newgrf_railtype.cpp:162
TriggerStationRandomisation
void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRandomTrigger trigger, CargoID cargo_type)
Trigger station randomisation.
Definition: newgrf_station.cpp:964
GetCompanyInfo
uint32 GetCompanyInfo(CompanyID owner, const Livery *l)
Returns company information like in vehicle var 43 or station var 43.
Definition: newgrf_commons.cpp:467
StationSpec::cargo_threshold
uint16 cargo_threshold
Cargo threshold for choosing between little and lots of cargo.
Definition: newgrf_station.h:154
BaseStation::speclist
StationSpecList * speclist
List of station specs of this station.
Definition: base_station_base.h:66
TrackBits
TrackBits
Bitfield corresponding to Track.
Definition: track_type.h:38
AnimationBase
Helper class for a unified approach to NewGRF animation.
Definition: newgrf_animation_base.h:29
DrawTileSprites::seq
const DrawTileSeqStruct * seq
Array of child sprites. Terminated with a terminator entry.
Definition: sprite.h:60
ToggleBit
static T ToggleBit(T &x, const uint8 y)
Toggles a bit in a variable.
Definition: bitmath_func.hpp:181
Debug
#define Debug(name, level, format_string,...)
Ouptut a line of debugging information.
Definition: debug.h:37
SetBit
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Definition: bitmath_func.hpp:121
Town
Town data structure.
Definition: town.h:50
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:378
StationSpec::grf_prop
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
Definition: newgrf_station.h:125
NewGRFClass::Get
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
Definition: newgrf_class_func.h:103
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:20
GetCustomStationFoundationRelocation
SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint layout, uint edge_info)
Resolve the sprites for custom station foundations.
Definition: newgrf_station.cpp:623
GetNearbyTile
TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets, Axis axis)
Get the tile at the given offset.
Definition: newgrf_commons.cpp:423
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:88
ETileArea
Definition: newgrf_station.cpp:59
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition: direction_type.h:123
NewGRFSpriteLayout::GetLayout
const DrawTileSeqStruct * GetLayout(PalSpriteID *ground) const
Returns the result spritelayout after preprocessing.
Definition: newgrf_commons.h:163
ATP_TTDP_LARGE
@ ATP_TTDP_LARGE
Same as AT_LARGE.
Definition: newgrf_airport.h:83
BaseStation::GetNewGRFVariable
virtual uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const =0
Helper function to get a NewGRF variable that isn't implemented by the base class.
Station::bus_stops
RoadStop * bus_stops
All the road stops.
Definition: station_base.h:456
GRFFilePropsBase::local_id
uint16 local_id
id defined by the grf file for this entity
Definition: newgrf_commons.h:319
PalSpriteID::pal
PaletteID pal
The palette (use PAL_NONE) if not needed)
Definition: gfx_type.h:24
StationResolverObject
Station resolver.
Definition: newgrf_station.h:50
CBID_RANDOM_TRIGGER
@ CBID_RANDOM_TRIGGER
Set when calling a randomizing trigger (almost undocumented).
Definition: newgrf_callbacks.h:25
StationSpec::callback_mask
byte callback_mask
Bitmask of station callbacks that have to be called.
Definition: newgrf_station.h:158
FindRailStationEnd
static TileIndex FindRailStationEnd(TileIndex tile, TileIndexDiff delta, bool check_type, bool check_axis)
Find the end of a railway station, from the tile, in the direction of delta.
Definition: newgrf_station.cpp:143
StationAnimationBase
Helper class for animation control.
Definition: newgrf_station.cpp:907
ScopeResolver::ro
ResolverObject & ro
Surrounding resolver object.
Definition: newgrf_spritegroup.h:289
GRFFilePropsBase::grffile
const struct GRFFile * grffile
grf file that introduced this entity
Definition: newgrf_commons.h:320
CBM_STATION_SPRITE_LAYOUT
@ CBM_STATION_SPRITE_LAYOUT
Use callback to select a sprite layout to use.
Definition: newgrf_callbacks.h:304
Swap
static void Swap(T &a, T &b)
Type safe swap operation.
Definition: math_func.hpp:215
INVALID_AXIS
@ INVALID_AXIS
Flag for an invalid Axis.
Definition: direction_type.h:127
Airport::GetSpec
const AirportSpec * GetSpec() const
Get the AirportSpec that from the airport type of this airport.
Definition: station_base.h:317
free
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: stdafx.h:460
CT_INVALID
@ CT_INVALID
Invalid cargo type.
Definition: cargo_type.h:69
DIAGDIR_NE
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Definition: direction_type.h:79
StationScopeResolver::GetVariable
uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override
Get a variable value.
Definition: newgrf_station.cpp:271
DrawStationTile
bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station)
Draw representation of a station tile for GUI purposes.
Definition: newgrf_station.cpp:780
StationUpdateCachedTriggers
void StationUpdateCachedTriggers(BaseStation *st)
Update the cached animation trigger bitmask for a station.
Definition: newgrf_station.cpp:1046
BaseStation::build_date
Date build_date
Date of construction.
Definition: base_station_base.h:68
StationResolverObject::StationResolverObject
StationResolverObject(const StationSpec *statspec, BaseStation *st, TileIndex tile, CallbackID callback=CBID_NO_CALLBACK, uint32 callback_param1=0, uint32 callback_param2=0)
Resolver for stations.
Definition: newgrf_station.cpp:559
CBID_STATION_SPRITE_LAYOUT
@ CBID_STATION_SPRITE_LAYOUT
Choose a sprite layout to draw, instead of the standard 0-7 range.
Definition: newgrf_callbacks.h:42
newgrf_cargo.h
GoodsEntry::HasVehicleEverTriedLoading
bool HasVehicleEverTriedLoading() const
Reports whether a vehicle has ever tried to load the cargo at this station.
Definition: station_base.h:264
StationSpec::cargo_triggers
CargoTypes cargo_triggers
Bitmask of cargo types which cause trigger re-randomizing.
Definition: newgrf_station.h:156
StationScopeResolver::tile
TileIndex tile
Tile of the station.
Definition: newgrf_station.h:25
SpriteGroup
Definition: newgrf_spritegroup.h:57
RailtypeInfo::GetRailtypeSpriteOffset
uint GetRailtypeSpriteOffset() const
Offset between the current railtype and normal rail.
Definition: rail.h:292
StationSpec::wires
byte wires
Bitmask of base tiles (0 - 7) which should contain elrail wires.
Definition: newgrf_station.h:163
newgrf_railtype.h
GetTerrainType
uint32 GetTerrainType(TileIndex tile, TileContext context)
Function used by houses (and soon industries) to get information on type of "terrain" the tile it is ...
Definition: newgrf_commons.cpp:348
StationSpec::blocked
byte blocked
Bitmask of base tiles (0 - 7) which are blocked to trains.
Definition: newgrf_station.h:164
debug.h
DAYS_TILL_ORIGINAL_BASE_YEAR
#define DAYS_TILL_ORIGINAL_BASE_YEAR
The offset in days from the '_date == 0' till 'ConvertYMDToDate(ORIGINAL_BASE_YEAR,...
Definition: date_type.h:81
GoodsEntry::GES_LAST_MONTH
@ GES_LAST_MONTH
Set when cargo was delivered for final delivery last month.
Definition: station_base.h:196
StationResolverObject::GetFeature
GrfSpecFeature GetFeature() const override
Get the feature number being resolved for.
Definition: newgrf_station.cpp:540
AXIS_X
@ AXIS_X
The X axis.
Definition: direction_type.h:124