OpenTTD Source: src/newgrf_roadstop.cpp Source File

OpenTTD Source 15.0-RC2

newgrf_roadstop.cpp
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#include "stdafx.h"
11#include "debug.h"
12#include "station_base.h"
13#include "roadstop_base.h"
14#include "newgrf_badge.h"
15#include "newgrf_roadstop.h"
16#include "newgrf_cargo.h"
17#include "newgrf_roadtype.h"
18#include "gfx_type.h"
19#include "company_func.h"
20#include "road.h"
21#include "window_type.h"
22#include "timer/timer_game_calendar.h"
23#include "town.h"
24#include "tile_cmd.h"
25#include "viewport_func.h"
26#include "newgrf_animation_base.h"
27#include "newgrf_sound.h"
28
29#include "table/strings.h"
30
31#include "newgrf_class_func.h"
32
33#include "safeguards.h"
34
35template <>
36void RoadStopClass::InsertDefaults()
37{
38 /* Set up initial data */
39 RoadStopClass::Get(RoadStopClass::Allocate(ROADSTOP_CLASS_LABEL_DEFAULT))->name = STR_STATION_CLASS_DFLT;
40 RoadStopClass::Get(RoadStopClass::Allocate(ROADSTOP_CLASS_LABEL_DEFAULT))->Insert(nullptr);
41 RoadStopClass::Get(RoadStopClass::Allocate(ROADSTOP_CLASS_LABEL_WAYPOINT))->name = STR_STATION_CLASS_WAYP;
42 RoadStopClass::Get(RoadStopClass::Allocate(ROADSTOP_CLASS_LABEL_WAYPOINT))->Insert(nullptr);
43}
44
45template <>
46bool RoadStopClass::IsUIAvailable(uint) const
47{
48 return true;
49}
50
51/* Instantiate RoadStopClass. */
52template class NewGRFClass<RoadStopSpec, RoadStopClassID, ROADSTOP_CLASS_MAX>;
53
54static const uint NUM_ROADSTOPSPECS_PER_STATION = 63;
55
56uint32_t RoadStopScopeResolver::GetRandomBits() const
57{
58 if (this->st == nullptr) return 0;
59
60 uint32_t bits = this->st->random_bits;
61 if (this->tile != INVALID_TILE && Station::IsExpected(this->st)) {
62 bits |= Station::From(this->st)->GetRoadStopRandomBits(this->tile) << 16;
63 }
64 return bits;
65}
66
67uint32_t RoadStopScopeResolver::GetRandomTriggers() const
68{
69 return this->st == nullptr ? 0 : this->st->waiting_random_triggers.base();
70}
71
72uint32_t RoadStopScopeResolver::GetVariable(uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const
73{
74 auto get_road_type_variable = [&](RoadTramType rtt) -> uint32_t {
75 RoadType rt;
76 if (this->tile == INVALID_TILE) {
77 rt = (GetRoadTramType(this->roadtype) == rtt) ? this->roadtype : INVALID_ROADTYPE;
78 } else {
79 rt = GetRoadType(this->tile, rtt);
80 }
81 if (rt == INVALID_ROADTYPE) {
82 return 0xFFFFFFFF;
83 } else {
84 return GetReverseRoadTypeTranslation(rt, this->roadstopspec->grf_prop.grffile);
85 }
86 };
87
88 switch (variable) {
89 /* View/rotation */
90 case 0x40: return this->view;
91
92 /* Stop type: 0: bus, 1: truck, 2: waypoint */
93 case 0x41:
94 if (this->type == StationType::Bus) return 0;
95 if (this->type == StationType::Truck) return 1;
96 return 2;
97
98 /* Terrain type */
99 case 0x42: return this->tile == INVALID_TILE ? 0 : (GetTileSlope(this->tile) << 8 | GetTerrainType(this->tile, TCX_NORMAL));
100
101 /* Road type */
102 case 0x43: return get_road_type_variable(RTT_ROAD);
103
104 /* Tram type */
105 case 0x44: return get_road_type_variable(RTT_TRAM);
106
107 /* Town zone and Manhattan distance of closest town */
108 case 0x45: {
109 if (this->tile == INVALID_TILE) return to_underlying(HouseZone::TownEdge) << 16;
110 const Town *t = (this->st == nullptr) ? ClosestTownFromTile(this->tile, UINT_MAX) : this->st->town;
111 return t != nullptr ? (to_underlying(GetTownRadiusGroup(t, this->tile)) << 16 | ClampTo<uint16_t>(DistanceManhattan(this->tile, t->xy))) : to_underlying(HouseZone::TownEdge) << 16;
112 }
113
114 /* Get square of Euclidean distance of closest town */
115 case 0x46: {
116 if (this->tile == INVALID_TILE) return 0;
117 const Town *t = (this->st == nullptr) ? ClosestTownFromTile(this->tile, UINT_MAX) : this->st->town;
118 return t != nullptr ? DistanceSquare(this->tile, t->xy) : 0;
119 }
120
121 /* Company information */
122 case 0x47: return GetCompanyInfo(this->st == nullptr ? _current_company : this->st->owner);
123
124 /* Animation frame */
125 case 0x49: return this->tile == INVALID_TILE ? 0 : this->st->GetRoadStopAnimationFrame(this->tile);
126
127 /* Misc info */
128 case 0x50: {
129 uint32_t result = 0;
130 if (this->tile == INVALID_TILE) {
131 SetBit(result, 4);
132 }
133 return result;
134 }
135
136 /* Variables which use the parameter */
137 /* Variables 0x60 to 0x65 and 0x69 are handled separately below */
138
139 /* Animation frame of nearby tile */
140 case 0x66: {
141 if (this->tile == INVALID_TILE) return UINT_MAX;
142 TileIndex tile = this->tile;
143 if (parameter != 0) tile = GetNearbyTile(parameter, tile);
144 return (IsAnyRoadStopTile(tile) && GetStationIndex(tile) == this->st->index) ? this->st->GetRoadStopAnimationFrame(tile) : UINT_MAX;
145 }
146
147 /* Land info of nearby tile */
148 case 0x67: {
149 if (this->tile == INVALID_TILE) return 0;
150 TileIndex tile = this->tile;
151 if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required
152 return GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8);
153 }
154
155 /* Road stop info of nearby tiles */
156 case 0x68: {
157 if (this->tile == INVALID_TILE) return 0xFFFFFFFF;
158 TileIndex nearby_tile = GetNearbyTile(parameter, this->tile);
159
160 if (!IsAnyRoadStopTile(nearby_tile)) return 0xFFFFFFFF;
161
162 uint32_t grfid = this->st->roadstop_speclist[GetCustomRoadStopSpecIndex(this->tile)].grfid;
163 bool same_orientation = GetStationGfx(this->tile) == GetStationGfx(nearby_tile);
164 bool same_station = GetStationIndex(nearby_tile) == this->st->index;
165 uint32_t res = GetStationGfx(nearby_tile) << 12 | !same_orientation << 11 | !!same_station << 10;
166 StationType type = GetStationType(nearby_tile);
167 if (type == StationType::Truck) res |= (1 << 16);
168 if (type == StationType::RoadWaypoint) res |= (2 << 16);
169 if (type == this->type) SetBit(res, 20);
170
171 if (IsCustomRoadStopSpecIndex(nearby_tile)) {
172 const auto &sm = BaseStation::GetByTile(nearby_tile)->roadstop_speclist[GetCustomRoadStopSpecIndex(nearby_tile)];
173 res |= 1 << (sm.grfid != grfid ? 9 : 8) | ClampTo<uint8_t>(sm.localidx);
174 }
175 return res;
176 }
177
178 /* GRFID of nearby road stop tiles */
179 case 0x6A: {
180 if (this->tile == INVALID_TILE) return 0xFFFFFFFF;
181 TileIndex nearby_tile = GetNearbyTile(parameter, this->tile);
182
183 if (!IsAnyRoadStopTile(nearby_tile)) return 0xFFFFFFFF;
184 if (!IsCustomRoadStopSpecIndex(nearby_tile)) return 0;
185
186 const auto &sm = BaseStation::GetByTile(nearby_tile)->roadstop_speclist[GetCustomRoadStopSpecIndex(nearby_tile)];
187 return sm.grfid;
188 }
189
190 /* 16 bit road stop ID of nearby tiles */
191 case 0x6B: {
192 if (this->tile == INVALID_TILE) return 0xFFFFFFFF;
193 TileIndex nearby_tile = GetNearbyTile(parameter, this->tile);
194
195 if (!IsAnyRoadStopTile(nearby_tile)) return 0xFFFFFFFF;
196 if (!IsCustomRoadStopSpecIndex(nearby_tile)) return 0xFFFE;
197
198 uint32_t grfid = this->st->roadstop_speclist[GetCustomRoadStopSpecIndex(this->tile)].grfid;
199
200 const auto &sm = BaseStation::GetByTile(nearby_tile)->roadstop_speclist[GetCustomRoadStopSpecIndex(nearby_tile)];
201 if (sm.grfid == grfid) {
202 return sm.localidx;
203 }
204
205 return 0xFFFE;
206 }
207
208 case 0x7A: return GetBadgeVariableResult(*this->ro.grffile, this->roadstopspec->badges, parameter);
209
210 case 0xF0: return this->st == nullptr ? 0 : this->st->facilities.base(); // facilities
211
212 case 0xFA: return ClampTo<uint16_t>((this->st == nullptr ? TimerGameCalendar::date : this->st->build_date) - CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR); // build date
213 }
214
215 if (this->st != nullptr) return this->st->GetNewGRFVariable(this->ro, variable, parameter, available);
216
217 available = false;
218 return UINT_MAX;
219}
220
221RoadStopResolverObject::RoadStopResolverObject(const RoadStopSpec *roadstopspec, BaseStation *st, TileIndex tile, RoadType roadtype, StationType type, uint8_t view,
222 CallbackID callback, uint32_t param1, uint32_t param2)
223 : SpecializedResolverObject<StationRandomTriggers>(roadstopspec->grf_prop.grffile, callback, param1, param2), roadstop_scope(*this, st, roadstopspec, tile, roadtype, type, view)
224{
225 CargoType ctype = CargoGRFFileProps::SG_DEFAULT_NA;
226
227 if (st == nullptr) {
228 /* No station, so we are in a purchase list */
229 ctype = CargoGRFFileProps::SG_PURCHASE;
230 } else if (Station::IsExpected(st)) {
231 const Station *station = Station::From(st);
232 /* Pick the first cargo that we have waiting */
233 for (const auto &[cargo, spritegroup] : roadstopspec->grf_prop.spritegroups) {
234 if (cargo < NUM_CARGO && station->goods[cargo].HasData() && station->goods[cargo].GetData().cargo.TotalCount() > 0) {
235 ctype = cargo;
236 this->root_spritegroup = spritegroup;
237 break;
238 }
239 }
240 }
241
242 this->root_spritegroup = this->roadstop_scope.roadstopspec->grf_prop.GetSpriteGroup(ctype);
243 if (this->root_spritegroup == nullptr) {
244 ctype = CargoGRFFileProps::SG_DEFAULT;
245 this->root_spritegroup = this->roadstop_scope.roadstopspec->grf_prop.GetSpriteGroup(ctype);
246 }
247
248 /* Remember the cargo type we've picked */
249 this->roadstop_scope.cargo_type = ctype;
250}
251
252 TownScopeResolver *RoadStopResolverObject::GetTown()
253{
254 if (!this->town_scope.has_value()) {
255 Town *t;
256 if (this->roadstop_scope.st != nullptr) {
257 t = this->roadstop_scope.st->town;
258 } else {
259 t = ClosestTownFromTile(this->roadstop_scope.tile, UINT_MAX);
260 }
261 if (t == nullptr) return nullptr;
262 this->town_scope.emplace(*this, t, this->roadstop_scope.st == nullptr);
263 }
264 return &*this->town_scope;
265}
266
267uint16_t GetRoadStopCallback(CallbackID callback, uint32_t param1, uint32_t param2, const RoadStopSpec *roadstopspec, BaseStation *st, TileIndex tile, RoadType roadtype, StationType type, uint8_t view, std::span<int32_t> regs100)
268{
269 RoadStopResolverObject object(roadstopspec, st, tile, roadtype, type, view, callback, param1, param2);
270 return object.ResolveCallback(regs100);
271}
272
282 void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec, StationType type, int view)
283{
284 assert(roadtype != INVALID_ROADTYPE);
285 assert(spec != nullptr);
286
287 const RoadTypeInfo *rti = GetRoadTypeInfo(roadtype);
288 RoadStopResolverObject object(spec, nullptr, INVALID_TILE, roadtype, type, view);
289 const auto *group = object.Resolve<TileLayoutSpriteGroup>();
290 if (group == nullptr) return;
291 auto processor = group->ProcessRegisters(object, nullptr);
292 auto dts = processor.GetLayout();
293
294 PaletteID palette = GetCompanyPalette(_local_company);
295
296 SpriteID image = dts.ground.sprite;
297 PaletteID pal = dts.ground.pal;
298
299 RoadStopDrawModes draw_mode;
300 if (spec->flags.Test(RoadStopSpecFlag::DrawModeRegister)) {
301 draw_mode = static_cast<RoadStopDrawModes>(object.GetRegister(0x100));
302 } else {
303 draw_mode = spec->draw_mode;
304 }
305
306 if (type == StationType::RoadWaypoint) {
307 DrawSprite(SPR_ROAD_PAVED_STRAIGHT_X, PAL_NONE, x, y);
308 if (draw_mode.Test(RoadStopDrawMode::WaypGround) && GB(image, 0, SPRITE_WIDTH) != 0) {
309 DrawSprite(image, GroundSpritePaletteTransform(image, pal, palette), x, y);
310 }
311 } else if (GB(image, 0, SPRITE_WIDTH) != 0) {
312 DrawSprite(image, GroundSpritePaletteTransform(image, pal, palette), x, y);
313 }
314
315 if (view >= 4) {
316 /* Drive-through stop */
317 uint sprite_offset = 5 - view;
318
319 /* Road underlay takes precedence over tram */
320 if (type == StationType::RoadWaypoint || draw_mode.Test(RoadStopDrawMode::Overlay)) {
321 if (rti->UsesOverlay()) {
322 SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_GROUND);
323 DrawSprite(ground + sprite_offset, PAL_NONE, x, y);
324
325 SpriteID overlay = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_OVERLAY);
326 if (overlay) DrawSprite(overlay + sprite_offset, PAL_NONE, x, y);
327 } else if (RoadTypeIsTram(roadtype)) {
328 DrawSprite(SPR_TRAMWAY_TRAM + sprite_offset, PAL_NONE, x, y);
329 }
330 }
331 } else {
332 /* Bay stop */
333 if (draw_mode.Test(RoadStopDrawMode::Road) && rti->UsesOverlay()) {
334 SpriteID ground = GetCustomRoadSprite(rti, INVALID_TILE, ROTSG_ROADSTOP);
335 DrawSprite(ground + view, PAL_NONE, x, y);
336 }
337 }
338
339 DrawCommonTileSeqInGUI(x, y, &dts, 0, 0, palette, true);
340}
341
342std::optional<SpriteLayoutProcessor> GetRoadStopLayout(TileInfo *ti, const RoadStopSpec *spec, BaseStation *st, StationType type, int view, std::span<int32_t> regs100)
343{
344 RoadStopResolverObject object(spec, st, ti->tile, INVALID_ROADTYPE, type, view);
345 auto group = object.Resolve<TileLayoutSpriteGroup>();
346 if (group == nullptr) return std::nullopt;
347 for (uint i = 0; i < regs100.size(); ++i) {
348 regs100[i] = object.GetRegister(0x100 + i);
349 }
350 return group->ProcessRegisters(object, nullptr);
351}
352
354uint16_t GetAnimRoadStopCallback(CallbackID callback, uint32_t param1, uint32_t param2, const RoadStopSpec *roadstopspec, BaseStation *st, TileIndex tile, int)
355{
356 return GetRoadStopCallback(callback, param1, param2, roadstopspec, st, tile, INVALID_ROADTYPE, GetStationType(tile), GetStationGfx(tile));
357}
358
359 struct RoadStopAnimationFrameAnimationHelper {
360 static uint8_t Get(BaseStation *st, TileIndex tile) { return st->GetRoadStopAnimationFrame(tile); }
361 static bool Set(BaseStation *st, TileIndex tile, uint8_t frame) { return st->SetRoadStopAnimationFrame(tile, frame); }
362};
363
365 struct RoadStopAnimationBase : public AnimationBase<RoadStopAnimationBase, RoadStopSpec, BaseStation, int, GetAnimRoadStopCallback, RoadStopAnimationFrameAnimationHelper> {
366 static constexpr CallbackID cb_animation_speed = CBID_STATION_ANIMATION_SPEED;
367 static constexpr CallbackID cb_animation_next_frame = CBID_STATION_ANIMATION_NEXT_FRAME;
368
369 static constexpr RoadStopCallbackMask cbm_animation_speed = RoadStopCallbackMask::AnimationSpeed;
370 static constexpr RoadStopCallbackMask cbm_animation_next_frame = RoadStopCallbackMask::AnimationNextFrame;
371};
372
373void AnimateRoadStopTile(TileIndex tile)
374{
375 const RoadStopSpec *ss = GetRoadStopSpec(tile);
376 if (ss == nullptr) return;
377
378 RoadStopAnimationBase::AnimateTile(ss, BaseStation::GetByTile(tile), tile, ss->flags.Test(RoadStopSpecFlag::Cb141RandomBits));
379}
380
381void TriggerRoadStopAnimation(BaseStation *st, TileIndex trigger_tile, StationAnimationTrigger trigger, CargoType cargo_type)
382{
383 assert(st != nullptr);
384
385 /* Check the cached animation trigger bitmask to see if we need
386 * to bother with any further processing. */
387 if (!st->cached_roadstop_anim_triggers.Test(trigger)) return;
388
389 uint16_t random_bits = Random();
390 auto process_tile = [&](TileIndex cur_tile) {
391 const RoadStopSpec *ss = GetRoadStopSpec(cur_tile);
392 if (ss != nullptr && ss->animation.triggers.Test(trigger)) {
393 uint8_t var18_extra = 0;
394 if (IsValidCargoType(cargo_type)) {
395 var18_extra |= ss->grf_prop.grffile->cargo_map[cargo_type] << 8;
396 }
397 RoadStopAnimationBase::ChangeAnimationFrame(CBID_STATION_ANIMATION_TRIGGER, ss, st, cur_tile, (random_bits << 16) | GB(Random(), 0, 16), to_underlying(trigger) | var18_extra);
398 }
399 };
400
401 if (trigger == StationAnimationTrigger::NewCargo || trigger == StationAnimationTrigger::CargoTaken || trigger == StationAnimationTrigger::AcceptanceTick) {
402 for (const RoadStopTileData &tile_data : st->custom_roadstop_tile_data) {
403 process_tile(tile_data.tile);
404 }
405 } else {
406 process_tile(trigger_tile);
407 }
408}
409
418 void TriggerRoadStopRandomisation(BaseStation *st, TileIndex tile, StationRandomTrigger trigger, CargoType cargo_type)
419{
420 assert(st != nullptr);
421
422 /* Check the cached cargo trigger bitmask to see if we need
423 * to bother with any further processing.
424 * Note: cached_roadstop_cargo_triggers must be non-zero even for cargo-independent triggers. */
425 if (st->cached_roadstop_cargo_triggers == 0) return;
426 if (IsValidCargoType(cargo_type) && !HasBit(st->cached_roadstop_cargo_triggers, cargo_type)) return;
427
428 st->waiting_random_triggers.Set(trigger);
429
430 uint32_t whole_reseed = 0;
431
432 /* Bitmask of completely empty cargo types to be matched. */
433 CargoTypes empty_mask{};
434 if (trigger == StationRandomTrigger::CargoTaken) {
435 empty_mask = GetEmptyMask(Station::From(st));
436 }
437
438 StationRandomTriggers used_random_triggers;
439 auto process_tile = [&](TileIndex cur_tile) {
440 const RoadStopSpec *ss = GetRoadStopSpec(cur_tile);
441 if (ss == nullptr) return;
442
443 /* Cargo taken "will only be triggered if all of those
444 * cargo types have no more cargo waiting." */
445 if (trigger == StationRandomTrigger::CargoTaken) {
446 if ((ss->cargo_triggers & ~empty_mask) != 0) return;
447 }
448
449 if (!IsValidCargoType(cargo_type) || HasBit(ss->cargo_triggers, cargo_type)) {
450 RoadStopResolverObject object(ss, st, cur_tile, INVALID_ROADTYPE, GetStationType(cur_tile), GetStationGfx(cur_tile));
451 object.SetWaitingRandomTriggers(st->waiting_random_triggers);
452
453 object.ResolveRerandomisation();
454
455 used_random_triggers.Set(object.GetUsedRandomTriggers());
456
457 uint32_t reseed = object.GetReseedSum();
458 if (reseed != 0) {
459 whole_reseed |= reseed;
460 reseed >>= 16;
461
462 /* Set individual tile random bits */
463 uint8_t random_bits = st->GetRoadStopRandomBits(cur_tile);
464 random_bits &= ~reseed;
465 random_bits |= Random() & reseed;
466 st->SetRoadStopRandomBits(cur_tile, random_bits);
467
468 MarkTileDirtyByTile(cur_tile);
469 }
470 }
471 };
472 if (trigger == StationRandomTrigger::NewCargo || trigger == StationRandomTrigger::CargoTaken) {
473 for (const RoadStopTileData &tile_data : st->custom_roadstop_tile_data) {
474 process_tile(tile_data.tile);
475 }
476 } else {
477 process_tile(tile);
478 }
479
480 /* Update whole station random bits */
481 st->waiting_random_triggers.Reset(used_random_triggers);
482 if ((whole_reseed & 0xFFFF) != 0) {
483 st->random_bits &= ~whole_reseed;
484 st->random_bits |= Random() & whole_reseed;
485 }
486}
487
494 bool GetIfNewStopsByType(RoadStopType rs, RoadType roadtype)
495{
496 for (const auto &cls : RoadStopClass::Classes()) {
497 /* Ignore the waypoint class. */
498 if (IsWaypointClass(cls)) continue;
499 /* Ignore the default class with only the default station. */
500 if (cls.Index() == ROADSTOP_CLASS_DFLT && cls.GetSpecCount() == 1) continue;
501 if (GetIfClassHasNewStopsByType(&cls, rs, roadtype)) return true;
502 }
503 return false;
504}
505
513 bool GetIfClassHasNewStopsByType(const RoadStopClass *roadstopclass, RoadStopType rs, RoadType roadtype)
514{
515 for (const auto spec : roadstopclass->Specs()) {
516 if (GetIfStopIsForType(spec, rs, roadtype)) return true;
517 }
518 return false;
519}
520
528 bool GetIfStopIsForType(const RoadStopSpec *roadstopspec, RoadStopType rs, RoadType roadtype)
529{
530 /* The roadstopspec is nullptr, must be the default station, always return true. */
531 if (roadstopspec == nullptr) return true;
532
533 if (roadstopspec->flags.Test(RoadStopSpecFlag::RoadOnly) && !RoadTypeIsRoad(roadtype)) return false;
534 if (roadstopspec->flags.Test(RoadStopSpecFlag::TramOnly) && !RoadTypeIsTram(roadtype)) return false;
535
536 if (roadstopspec->stop_type == ROADSTOPTYPE_ALL) return true;
537
538 switch (rs) {
539 case RoadStopType::Bus:
540 if (roadstopspec->stop_type == ROADSTOPTYPE_PASSENGER) return true;
541 break;
542
543 case RoadStopType::Truck:
544 if (roadstopspec->stop_type == ROADSTOPTYPE_FREIGHT) return true;
545 break;
546
547 default:
548 NOT_REACHED();
549 }
550 return false;
551}
552
553const RoadStopSpec *GetRoadStopSpec(TileIndex t)
554{
555 if (!IsCustomRoadStopSpecIndex(t)) return nullptr;
556
557 const BaseStation *st = BaseStation::GetByTile(t);
558 uint specindex = GetCustomRoadStopSpecIndex(t);
559 return specindex < st->roadstop_speclist.size() ? st->roadstop_speclist[specindex].spec : nullptr;
560}
561
568std::optional<uint8_t> AllocateSpecToRoadStop(const RoadStopSpec *spec, BaseStation *st)
569{
570 uint i;
571
572 if (spec == nullptr) return 0;
573
574 /* If station doesn't exist yet then the first slot is available. */
575 if (st == nullptr) return 1;
576
577 /* Try to find the same spec and return that one */
578 for (i = 1; i < st->roadstop_speclist.size() && i < NUM_ROADSTOPSPECS_PER_STATION; i++) {
579 if (st->roadstop_speclist[i].spec == spec) return i;
580 }
581
582 /* Try to find an unused spec slot */
583 for (i = 1; i < st->roadstop_speclist.size() && i < NUM_ROADSTOPSPECS_PER_STATION; i++) {
584 if (st->roadstop_speclist[i].spec == nullptr && st->roadstop_speclist[i].grfid == 0) break;
585 }
586
587 if (i == NUM_ROADSTOPSPECS_PER_STATION) {
588 /* Full, give up */
589 return std::nullopt;
590 }
591
592 return i;
593}
594
601 void AssignSpecToRoadStop(const RoadStopSpec *spec, BaseStation *st, uint8_t specindex)
602{
603 if (specindex == 0) return;
604 if (specindex >= st->roadstop_speclist.size()) st->roadstop_speclist.resize(specindex + 1);
605
606 st->roadstop_speclist[specindex].spec = spec;
607 st->roadstop_speclist[specindex].grfid = spec->grf_prop.grfid;
608 st->roadstop_speclist[specindex].localidx = spec->grf_prop.local_id;
609
610 RoadStopUpdateCachedTriggers(st);
611}
612
618 void DeallocateSpecFromRoadStop(BaseStation *st, uint8_t specindex)
619{
620 /* specindex of 0 (default) is never freeable */
621 if (specindex == 0) return;
622
623 /* Check custom road stop tiles if the specindex is still in use */
624 for (const RoadStopTileData &tile_data : st->custom_roadstop_tile_data) {
625 if (GetCustomRoadStopSpecIndex(tile_data.tile) == specindex) {
626 return;
627 }
628 }
629
630 /* This specindex is no longer in use, so deallocate it */
631 st->roadstop_speclist[specindex].spec = nullptr;
632 st->roadstop_speclist[specindex].grfid = 0;
633 st->roadstop_speclist[specindex].localidx = 0;
634
635 /* If this was the highest spec index, reallocate */
636 if (specindex == st->roadstop_speclist.size() - 1) {
637 size_t num_specs;
638 for (num_specs = st->roadstop_speclist.size() - 1; num_specs > 0; num_specs--) {
639 if (st->roadstop_speclist[num_specs].grfid != 0) break;
640 }
641
642 if (num_specs > 0) {
643 st->roadstop_speclist.resize(num_specs + 1);
644 } else {
645 st->roadstop_speclist.clear();
646 st->cached_roadstop_anim_triggers = {};
647 st->cached_roadstop_cargo_triggers = 0;
648 return;
649 }
650 }
651
652 RoadStopUpdateCachedTriggers(st);
653}
654
659 void RoadStopUpdateCachedTriggers(BaseStation *st)
660{
661 st->cached_roadstop_anim_triggers = {};
662 st->cached_roadstop_cargo_triggers = 0;
663
664 /* Combine animation trigger bitmask for all road stop specs
665 * of this station. */
666 for (const auto &sm : GetStationSpecList<RoadStopSpec>(st)) {
667 if (sm.spec == nullptr) continue;
668 st->cached_roadstop_anim_triggers.Set(sm.spec->animation.triggers);
669 st->cached_roadstop_cargo_triggers |= sm.spec->cargo_triggers;
670 }
671}
GB
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Definition bitmath_func.hpp:32
SetBit
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
Definition bitmath_func.hpp:121
HasBit
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition bitmath_func.hpp:103
CargoType
uint8_t CargoType
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:21
IsValidCargoType
bool IsValidCargoType(CargoType cargo)
Test whether cargo type is not INVALID_CARGO.
Definition cargo_type.h:104
BaseBitSet::Test
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Definition base_bitset_type.hpp:141
BaseBitSet::base
constexpr Tstorage base() const noexcept
Retrieve the raw value behind this bit set.
Definition base_bitset_type.hpp:219
BaseBitSet::Reset
constexpr Timpl & Reset()
Reset all bits.
Definition base_bitset_type.hpp:83
BaseBitSet::Set
constexpr Timpl & Set()
Set all bits.
Definition base_bitset_type.hpp:40
EnumBitSet< StationRandomTrigger, uint8_t >
NewGRFClass
Struct containing information relating to NewGRF classes for stations and airports.
Definition newgrf_class.h:26
NewGRFClass::Classes
static std::span< NewGRFClass< Tspec, Tindex, Tmax > const > Classes()
Get read-only span of all classes of this type.
Definition newgrf_class.h:64
NewGRFClass::name
StringID name
Name of this class.
Definition newgrf_class.h:49
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:40
NewGRFClass::Insert
void Insert(Tspec *spec)
Insert a spec into the class, and update its index.
Definition newgrf_class_func.h:55
NewGRFClass::Specs
std::span< Tspec *const > Specs() const
Get read-only span of specs of this class.
Definition newgrf_class.h:58
NewGRFClass::Get
static NewGRFClass * Get(Tindex class_index)
Get a particular class.
Definition newgrf_class_func.h:82
NewGRFClass::Allocate
static Tindex Allocate(uint32_t global_id)
Allocate a class with a given global class ID.
Definition newgrf_class_func.h:32
NewGRFClass::InsertDefaults
static void InsertDefaults()
Initialise the defaults.
Definition newgrf_airport.cpp:31
RoadTypeInfo
Definition road.h:52
SpriteLayoutProcessor::GetLayout
DrawTileSpriteSpan GetLayout() const
Returns the result spritelayout after preprocessing.
Definition newgrf_commons.h:167
TimerGameCalendar::date
static Date date
Current date in days (day counter).
Definition timer_game_calendar.h:33
TimerGameConst< struct Calendar >::DAYS_TILL_ORIGINAL_BASE_YEAR
static constexpr TimerGame< struct Calendar >::Date DAYS_TILL_ORIGINAL_BASE_YEAR
The date of the first day of the original base year.
Definition timer_game_common.h:184
GetCompanyPalette
PaletteID GetCompanyPalette(CompanyID company)
Get the palette for recolouring with a company colour.
Definition company_cmd.cpp:164
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition company_cmd.cpp:55
_current_company
CompanyID _current_company
Company currently doing an action.
Definition company_cmd.cpp:56
company_func.h
Functions related to companies.
debug.h
Functions related to debugging.
to_underlying
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
Definition enum_type.hpp:17
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:1031
gfx_type.h
Types related to the graphics and/or input devices.
SpriteID
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition gfx_type.h:17
PaletteID
uint32_t PaletteID
The number of the palette.
Definition gfx_type.h:18
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:2128
BorderFlag::Random
@ Random
Randomise borders.
DistanceSquare
uint DistanceSquare(TileIndex t0, TileIndex t1)
Gets the 'Square' distance between the two given tiles.
Definition map.cpp:175
DistanceManhattan
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
Definition map.cpp:158
newgrf_animation_base.h
Function implementations related to NewGRF animation.
GetBadgeVariableResult
uint32_t GetBadgeVariableResult(const GRFFile &grffile, std::span< const BadgeID > badges, uint32_t parameter)
Test for a matching badge in a list of badges, returning the number of matching bits.
Definition newgrf_badge.cpp:225
newgrf_badge.h
Functions related to NewGRF badges.
CallbackID
CallbackID
List of implemented NewGRF callbacks.
Definition newgrf_callbacks.h:22
CBID_STATION_ANIMATION_TRIGGER
@ CBID_STATION_ANIMATION_TRIGGER
Called for periodically starting or stopping the animation.
Definition newgrf_callbacks.h:187
CBID_STATION_ANIMATION_NEXT_FRAME
@ CBID_STATION_ANIMATION_NEXT_FRAME
Called to determine station tile next animation frame.
Definition newgrf_callbacks.h:190
CBID_STATION_ANIMATION_SPEED
@ CBID_STATION_ANIMATION_SPEED
Called to indicate how long the current animation frame should last.
Definition newgrf_callbacks.h:193
RoadStopCallbackMask
RoadStopCallbackMask
Callback masks for road stops.
Definition newgrf_callbacks.h:331
RoadStopCallbackMask::AnimationNextFrame
@ AnimationNextFrame
Use a custom next frame callback.
RoadStopCallbackMask::AnimationSpeed
@ AnimationSpeed
Customize the animation speed of the road stop.
newgrf_cargo.h
Cargo support for NewGRFs.
newgrf_class_func.h
Implementation of the NewGRF class' functions.
GetCompanyInfo
uint32_t GetCompanyInfo(CompanyID owner, const Livery *l)
Returns company information like in vehicle var 43 or station var 43.
Definition newgrf_commons.cpp:457
GetNearbyTileInformation
uint32_t 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:434
GetTerrainType
uint32_t 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:336
GetNearbyTile
TileIndex GetNearbyTile(uint8_t parameter, TileIndex tile, bool signed_offsets, Axis axis)
Get the tile at the given offset.
Definition newgrf_commons.cpp:411
TCX_NORMAL
@ TCX_NORMAL
Nothing special.
Definition newgrf_commons.h:25
newgrf_roadstop.h
NewGRF definitions and structures for road stops.
RoadStopDrawMode::Overlay
@ Overlay
Drive-through stops: Draw the road overlay, e.g. pavement.
RoadStopDrawMode::WaypGround
@ WaypGround
Waypoints: Draw the sprite layout ground tile (on top of the road)
RoadStopDrawMode::Road
@ Road
Bay stops: Draw the road itself.
IsWaypointClass
bool IsWaypointClass(const RoadStopClass &cls)
Test if a RoadStopClass is the waypoint class.
Definition newgrf_roadstop.h:190
ROADSTOP_CLASS_DFLT
@ ROADSTOP_CLASS_DFLT
Default road stop class.
Definition newgrf_roadstop.h:35
ROADSTOPTYPE_FREIGHT
@ ROADSTOPTYPE_FREIGHT
This RoadStop is for freight (truck) stops.
Definition newgrf_roadstop.h:47
ROADSTOPTYPE_ALL
@ ROADSTOPTYPE_ALL
This RoadStop is for both types of station road stops.
Definition newgrf_roadstop.h:48
ROADSTOPTYPE_PASSENGER
@ ROADSTOPTYPE_PASSENGER
This RoadStop is for passenger (bus) stops.
Definition newgrf_roadstop.h:46
RoadStopSpecFlag::RoadOnly
@ RoadOnly
Only show in the road build menu (not tram).
RoadStopSpecFlag::Cb141RandomBits
@ Cb141RandomBits
Callback 141 needs random bits.
RoadStopSpecFlag::TramOnly
@ TramOnly
Only show in the tram build menu (not road).
RoadStopSpecFlag::DrawModeRegister
@ DrawModeRegister
Read draw mode from register 0x100.
GetCustomRoadSprite
SpriteID GetCustomRoadSprite(const RoadTypeInfo *rti, TileIndex tile, RoadTypeSpriteGroup rtsg, TileContext context, uint *num_results)
Get the sprite to draw for the given tile.
Definition newgrf_roadtype.cpp:149
GetReverseRoadTypeTranslation
uint8_t GetReverseRoadTypeTranslation(RoadType roadtype, const GRFFile *grffile)
Perform a reverse roadtype lookup to get the GRF internal ID.
Definition newgrf_roadtype.cpp:201
newgrf_roadtype.h
NewGRF handling of road types.
newgrf_sound.h
Functions related to NewGRF provided sounds.
road.h
Road specific functions.
GetRoadTypeInfo
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
Definition road.h:215
ROTSG_OVERLAY
@ ROTSG_OVERLAY
Optional: Images for overlaying track.
Definition road.h:38
ROTSG_ROADSTOP
@ ROTSG_ROADSTOP
Required: Bay stop surface.
Definition road.h:47
ROTSG_GROUND
@ ROTSG_GROUND
Required: Main group of ground images.
Definition road.h:39
RoadTramType
RoadTramType
The different types of road type.
Definition road_type.h:37
RTT_ROAD
@ RTT_ROAD
Road road type.
Definition road_type.h:38
RTT_TRAM
@ RTT_TRAM
Tram road type.
Definition road_type.h:39
RoadType
RoadType
The different roadtypes we support.
Definition road_type.h:23
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition road_type.h:28
roadstop_base.h
Base class for roadstops.
safeguards.h
A number of safeguards to prevent using unsafe methods.
DrawCommonTileSeqInGUI
void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32_t orig_offset, uint32_t newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned)
Draws a tile sprite sequence in the GUI.
Definition sprite.cpp:86
GroundSpritePaletteTransform
PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
Definition sprite.h:174
SPRITE_WIDTH
static constexpr uint8_t SPRITE_WIDTH
number of bits for the sprite number
Definition sprites.h:1549
station_base.h
Base classes/functions for stations.
GetEmptyMask
CargoTypes GetEmptyMask(const Station *st)
Get a mask of the cargo types that are empty at the station.
Definition station_cmd.cpp:504
GetStationType
StationType GetStationType(Tile t)
Get the station type of this tile.
Definition station_map.h:44
GetStationGfx
StationGfx GetStationGfx(Tile t)
Get the station graphics of this tile.
Definition station_map.h:68
GetCustomRoadStopSpecIndex
uint GetCustomRoadStopSpecIndex(Tile t)
Get the custom road stop spec for this tile.
Definition station_map.h:678
GetStationIndex
StationID GetStationIndex(Tile t)
Get StationID from a tile.
Definition station_map.h:28
IsCustomRoadStopSpecIndex
bool IsCustomRoadStopSpecIndex(Tile t)
Is there a custom road stop spec on this tile?
Definition station_map.h:654
IsAnyRoadStopTile
bool IsAnyRoadStopTile(Tile t)
Is tile t a road stop station?
Definition station_map.h:256
RoadStopType
RoadStopType
Types of RoadStops.
Definition station_type.h:43
RoadStopType::Bus
@ Bus
A standard stop for buses.
RoadStopType::Truck
@ Truck
A standard stop for trucks.
StationType
StationType
Station types.
Definition station_type.h:29
StationRandomTrigger
StationRandomTrigger
Randomisation triggers for stations and roadstops.
Definition station_type.h:77
StationRandomTrigger::NewCargo
@ NewCargo
Trigger station on new cargo arrival.
StationRandomTrigger::CargoTaken
@ CargoTaken
Trigger station when cargo is completely taken.
StationAnimationTrigger
StationAnimationTrigger
Animation triggers for stations and roadstops.
Definition station_type.h:88
StationAnimationTrigger::NewCargo
@ NewCargo
Trigger station on new cargo arrival.
StationAnimationTrigger::AcceptanceTick
@ AcceptanceTick
Trigger station every 250 ticks.
StationAnimationTrigger::CargoTaken
@ CargoTaken
Trigger station when cargo is completely taken.
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
AnimationBase
Helper class for a unified approach to NewGRF animation.
Definition newgrf_animation_base.h:43
AnimationBase< RoadStopAnimationBase, RoadStopSpec, BaseStation, int, GetAnimRoadStopCallback, RoadStopAnimationFrameAnimationHelper >::AnimateTile
static void AnimateTile(const RoadStopSpec *spec, BaseStation *obj, TileIndex tile, bool random_animation, int extra_data=0)
Animate a single tile.
Definition newgrf_animation_base.h:52
AnimationBase< RoadStopAnimationBase, RoadStopSpec, BaseStation, int, GetAnimRoadStopCallback, RoadStopAnimationFrameAnimationHelper >::ChangeAnimationFrame
static void ChangeAnimationFrame(CallbackID cb, const RoadStopSpec *spec, BaseStation *obj, TileIndex tile, uint32_t random_bits, uint32_t 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:131
BaseStation
Base class for all station-ish types.
Definition base_station_base.h:58
BaseStation::GetNewGRFVariable
virtual uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint8_t variable, uint8_t parameter, bool &available) const =0
Helper function to get a NewGRF variable that isn't implemented by the base class.
BaseStation::roadstop_speclist
std::vector< SpecMapping< RoadStopSpec > > roadstop_speclist
List of road stop specs of this station.
Definition base_station_base.h:72
BaseStation::facilities
StationFacilities facilities
The facilities that this station has.
Definition base_station_base.h:69
BaseStation::owner
Owner owner
The owner of this station.
Definition base_station_base.h:68
BaseStation::cached_roadstop_anim_triggers
StationAnimationTriggers cached_roadstop_anim_triggers
NOSAVE: Combined animation trigger bitmask for road stops, used to determine if trigger processing sh...
Definition base_station_base.h:79
BaseStation::town
Town * town
The town this station is associated with.
Definition base_station_base.h:67
BaseStation::GetByTile
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
Definition base_station_base.h:160
BaseStation::cached_roadstop_cargo_triggers
CargoTypes cached_roadstop_cargo_triggers
NOSAVE: Combined cargo trigger bitmask for road stops.
Definition base_station_base.h:81
BaseStation::random_bits
uint16_t random_bits
Random bits assigned to this station.
Definition base_station_base.h:76
BaseStation::custom_roadstop_tile_data
std::vector< RoadStopTileData > custom_roadstop_tile_data
List of custom road stop tile data.
Definition base_station_base.h:86
BaseStation::build_date
TimerGameCalendar::Date build_date
Date of construction.
Definition base_station_base.h:74
BaseStation::waiting_random_triggers
StationRandomTriggers waiting_random_triggers
Waiting triggers (NewGRF), shared by all station parts/tiles, road stops, ... essentially useless and...
Definition base_station_base.h:77
CargoGRFFileProps::SG_PURCHASE
static constexpr CargoType SG_PURCHASE
Used in purchase lists before an item exists.
Definition newgrf_commons.h:457
CargoGRFFileProps::SG_DEFAULT
static constexpr CargoType SG_DEFAULT
Default type used when no more-specific cargo matches.
Definition newgrf_commons.h:456
CargoGRFFileProps::SG_DEFAULT_NA
static constexpr CargoType SG_DEFAULT_NA
Used only by stations and roads when no more-specific cargo matches.
Definition newgrf_commons.h:458
GRFFilePropsBase::grffile
const struct GRFFile * grffile
grf file that introduced this entity
Definition newgrf_commons.h:318
GRFFilePropsBase::local_id
uint16_t local_id
id defined by the grf file for this entity
Definition newgrf_commons.h:316
GRFFilePropsBase::grfid
uint32_t grfid
grfid that introduced this entity.
Definition newgrf_commons.h:317
GRFFile::cargo_map
std::array< uint8_t, NUM_CARGO > cargo_map
Inverse cargo translation table (CargoType -> local ID)
Definition newgrf.h:136
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition pool_type.hpp:286
ResolverObject::grffile
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
Definition newgrf_spritegroup.h:352
RoadStopAnimationBase
Helper class for animation control.
Definition newgrf_roadstop.cpp:365
RoadStopAnimationFrameAnimationHelper
Definition newgrf_roadstop.cpp:359
RoadStopResolverObject
Road stop resolver.
Definition newgrf_roadstop.h:106
RoadStopResolverObject::town_scope
std::optional< TownScopeResolver > town_scope
The town scope resolver (created on the first call).
Definition newgrf_roadstop.h:108
RoadStopResolverObject::roadstop_scope
RoadStopScopeResolver roadstop_scope
The stop scope resolver.
Definition newgrf_roadstop.h:107
RoadStopScopeResolver::view
uint8_t view
Station axis.
Definition newgrf_roadstop.h:91
RoadStopScopeResolver::roadtype
RoadType roadtype
Road type (used when no tile)
Definition newgrf_roadstop.h:92
RoadStopScopeResolver::GetVariable
uint32_t GetVariable(uint8_t variable, uint32_t parameter, bool &available) const override
Get a variable value.
Definition newgrf_roadstop.cpp:72
RoadStopScopeResolver::type
StationType type
Station type.
Definition newgrf_roadstop.h:90
RoadStopScopeResolver::roadstopspec
const struct RoadStopSpec * roadstopspec
Station (type) specification.
Definition newgrf_roadstop.h:88
RoadStopScopeResolver::st
struct BaseStation * st
Instance of the station.
Definition newgrf_roadstop.h:87
RoadStopScopeResolver::GetRandomTriggers
uint32_t GetRandomTriggers() const override
Get the triggers.
Definition newgrf_roadstop.cpp:67
RoadStopScopeResolver::tile
TileIndex tile
Tile of the station.
Definition newgrf_roadstop.h:86
RoadStopScopeResolver::GetRandomBits
uint32_t GetRandomBits() const override
Get a few random bits.
Definition newgrf_roadstop.cpp:56
RoadStopSpec
Road stop specification.
Definition newgrf_roadstop.h:129
RoadStopSpec::cargo_triggers
CargoTypes cargo_triggers
Bitmask of cargo types which cause trigger re-randomizing.
Definition newgrf_roadstop.h:138
RoadStopSpec::grf_prop
CargoGRFFileProps grf_prop
Link to NewGRF.
Definition newgrf_roadstop.h:130
RoadStopTileData
Definition base_station_base.h:29
ScopeResolver::ro
ResolverObject & ro
Surrounding resolver object.
Definition newgrf_spritegroup.h:270
SpecializedResolverObject
Specialization of ResolverObject with type-safe access to RandomTriggers.
Definition newgrf_spritegroup.h:450
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:229
SpecializedStation< Station, false >::From
static Station * From(BaseStation *st)
Converts a BaseStation to SpecializedStation with type checking.
Definition base_station_base.h:277
Station
Station data structure.
Definition station_base.h:500
Station::goods
std::array< GoodsEntry, NUM_CARGO > goods
Goods at this station.
Definition station_base.h:529
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
TileInfo
Tile information, used while rendering the tile.
Definition tile_cmd.h:30
TileInfo::tile
TileIndex tile
Tile index.
Definition tile_cmd.h:32
TileLayoutSpriteGroup
Action 2 sprite layout for houses, industry tiles, objects and airport tiles.
Definition newgrf_spritegroup.h:236
TileLayoutSpriteGroup::ProcessRegisters
SpriteLayoutProcessor ProcessRegisters(const ResolverObject &object, uint8_t *stage) const
Process registers and the construction stage into the sprite layout.
Definition newgrf_spritegroup.cpp:290
TownScopeResolver
Scope resolver for a town.
Definition newgrf_town.h:22
Town
Town data structure.
Definition town.h:63
Town::xy
TileIndex xy
town center tile
Definition town.h:64
tile_cmd.h
Generic 'commands' that can be performed on all tiles.
GetTileSlope
Slope GetTileSlope(TileIndex tile)
Return the slope of a given tile inside the map.
Definition tile_map.h:279
INVALID_TILE
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:95
timer_game_calendar.h
Definition of the game-calendar-timer.
town.h
Base of the town class.
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:3952
GetTownRadiusGroup
HouseZone GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
Definition town_cmd.cpp:2507
viewport_func.h
Functions related to (drawing on) viewports.
window_type.h
Types related to windows.