OpenTTD Source 20241224-master-gf74b0cf984
cargopacket.h
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#ifndef CARGOPACKET_H
11#define CARGOPACKET_H
12
13#include "core/pool_type.hpp"
14#include "economy_type.h"
15#include "station_type.h"
16#include "order_type.h"
17#include "cargo_type.h"
18#include "vehicle_type.h"
19#include "core/multimap.hpp"
20#include "saveload/saveload.h"
21
23typedef uint32_t CargoPacketID;
24struct CargoPacket;
25
30
31struct GoodsEntry; // forward-declare for Stage() and RerouteStalePackets()
32
33template <class Tinst, class Tcont> class CargoList;
34class StationCargoList; // forward-declare, so we can use it in VehicleCargoList.
36
40struct CargoPacket : CargoPacketPool::PoolItem<&_cargopacket_pool> {
41private:
42 /* A mathematical vector from (0,0). */
43 struct Vector {
44 int16_t x;
45 int16_t y;
46 };
47
48 uint16_t count = 0;
49 uint16_t periods_in_transit = 0;
50
52
55
58
59#ifdef WITH_ASSERT
60 bool in_vehicle = false;
61#endif /* WITH_ASSERT */
62
63 StationID first_station = INVALID_STATION;
64 StationID next_hop = INVALID_STATION;
65
67 template <class Tinst, class Tcont> friend class CargoList;
68 friend class VehicleCargoList;
69 friend class StationCargoList;
72public:
74 static const uint16_t MAX_COUNT = UINT16_MAX;
75
79 CargoPacket(uint16_t count, Money feeder_share, CargoPacket &original);
80
83
84 CargoPacket *Split(uint new_size);
85 void Merge(CargoPacket *cp);
86 void Reduce(uint count);
87
92 void SetNextHop(StationID next_hop)
93 {
94 this->next_hop = next_hop;
95 }
96
112 {
113 if (this->source_xy == INVALID_TILE) {
114 this->source_xy = tile;
115 }
116
117#ifdef WITH_ASSERT
118 assert(!this->in_vehicle);
119 this->in_vehicle = true;
120#endif /* WITH_ASSERT */
121
122 /* We want to calculate the vector from tile-unload to tile-load. As
123 * we currently only know the latter, add it. When we know where we unload,
124 * we subtract is, giving us our vector (unload - load). */
125 this->travelled.x += TileX(tile);
126 this->travelled.y += TileY(tile);
127 }
128
135 {
136#ifdef WITH_ASSERT
137 assert(this->in_vehicle);
138 this->in_vehicle = false;
139#endif /* WITH_ASSERT */
140
141 this->travelled.x -= TileX(tile);
142 this->travelled.y -= TileY(tile);
143 }
144
149 void AddFeederShare(Money new_share)
150 {
151 this->feeder_share += new_share;
152 }
153
158 inline uint16_t Count() const
159 {
160 return this->count;
161 }
162
168 inline Money GetFeederShare() const
169 {
170 return this->feeder_share;
171 }
172
179 inline Money GetFeederShare(uint part) const
180 {
181 return this->feeder_share * part / static_cast<uint>(this->count);
182 }
183
191 inline uint16_t GetPeriodsInTransit() const
192 {
193 return this->periods_in_transit;
194 }
195
201 {
202 return this->source_type;
203 }
204
209 inline SourceID GetSourceID() const
210 {
211 return this->source_id;
212 }
213
218 inline StationID GetFirstStation() const
219 {
220 return this->first_station;
221 }
222
229 inline uint GetDistance(TileIndex current_tile) const
230 {
231 assert(this->source_xy != INVALID_TILE);
232#ifdef WITH_ASSERT
233 assert(this->in_vehicle);
234#endif /* WITH_ASSERT */
235
236 /* Distance is always requested when the cargo is still inside the
237 * vehicle. So first finish the calculation for travelled to
238 * become a vector. */
239 auto local_travelled = travelled;
240 local_travelled.x -= TileX(current_tile);
241 local_travelled.y -= TileY(current_tile);
242
243 /* Cargo-movement is a vector that indicates how much the cargo has
244 * actually traveled in a vehicle. This is the distance you get paid
245 * for. However, one could construct a route where this vector would
246 * be really long. To not overpay the player, cap out at the distance
247 * between source and destination.
248 *
249 * This way of calculating is to counter people moving cargo for free
250 * and instantly in stations, where you deliver it in one part of the
251 * station and pick it up in another. By using the actual distance
252 * traveled in a vehicle, using this trick doesn't give you more money.
253 *
254 * However, especially in large networks with large transfer station,
255 * etc, one could actually make the route a lot longer. In that case,
256 * use the actual distance between source and destination.
257 */
258
259 uint distance_travelled = abs(local_travelled.x) + abs(local_travelled.y);
260 uint distance_source_dest = DistanceManhattan(this->source_xy, current_tile);
261 return std::min(distance_travelled, distance_source_dest);
262 }
263
268 inline StationID GetNextHop() const
269 {
270 return this->next_hop;
271 }
272
273 static void InvalidateAllFrom(SourceType src_type, SourceID src);
274 static void InvalidateAllFrom(StationID sid);
275 static void AfterLoad();
276};
277
282template <class Tinst, class Tcont>
284public:
286 typedef typename Tcont::iterator Iterator;
288 typedef typename Tcont::reverse_iterator ReverseIterator;
290 typedef typename Tcont::const_iterator ConstIterator;
292 typedef typename Tcont::const_reverse_iterator ConstReverseIterator;
293
296 MTA_BEGIN = 0,
301 MTA_END,
302 NUM_MOVE_TO_ACTION = MTA_END
303 };
304
305protected:
306 uint count;
308
309 Tcont packets;
310
311 void AddToCache(const CargoPacket *cp);
312
313 void RemoveFromCache(const CargoPacket *cp, uint count);
314
315 static bool TryMerge(CargoPacket *cp, CargoPacket *icp);
316
317public:
320
321 ~CargoList();
322
323 void OnCleanPool();
324
329 inline const Tcont *Packets() const
330 {
331 return &this->packets;
332 }
333
338 inline uint PeriodsInTransit() const
339 {
340 return this->count == 0 ? 0 : this->cargo_periods_in_transit / this->count;
341 }
342
343 void InvalidateCache();
344};
345
346typedef std::list<CargoPacket *> CargoPacketList;
347
351class VehicleCargoList : public CargoList<VehicleCargoList, CargoPacketList> {
352protected:
355
357 uint action_counts[NUM_MOVE_TO_ACTION];
358
359 template<class Taction>
360 void ShiftCargo(Taction action);
361
362 template<class Taction>
363 void PopCargo(Taction action);
364
368 inline void AssertCountConsistency() const
369 {
370 assert(this->action_counts[MTA_KEEP] +
371 this->action_counts[MTA_DELIVER] +
372 this->action_counts[MTA_TRANSFER] +
373 this->action_counts[MTA_LOAD] == this->count);
374 }
375
376 void AddToCache(const CargoPacket *cp);
377 void RemoveFromCache(const CargoPacket *cp, uint count);
378
379 void AddToMeta(const CargoPacket *cp, MoveToAction action);
380 void RemoveFromMeta(const CargoPacket *cp, MoveToAction action, uint count);
381
382 static MoveToAction ChooseAction(const CargoPacket *cp, StationID cargo_next,
383 StationID current_station, bool accepted, StationIDStack next_station);
384
385public:
387 friend class StationCargoList;
389 friend class CargoList<VehicleCargoList, CargoPacketList>;
390 /* So we can use private/protected variables in the saveload code */
391 friend class SlVehicleCommon;
392
393 friend class CargoShift;
394 friend class CargoTransfer;
395 friend class CargoDelivery;
396 template<class Tsource>
397 friend class CargoRemoval;
398 friend class CargoReturn;
399 friend class VehicleCargoReroute;
400
405 inline StationID GetFirstStation() const
406 {
407 return this->count == 0 ? INVALID_STATION : this->packets.front()->first_station;
408 }
409
414 inline Money GetFeederShare() const
415 {
416 return this->feeder_share;
417 }
418
424 inline uint ActionCount(MoveToAction action) const
425 {
426 return this->action_counts[action];
427 }
428
434 inline uint StoredCount() const
435 {
436 return this->count - this->action_counts[MTA_LOAD];
437 }
438
443 inline uint TotalCount() const
444 {
445 return this->count;
446 }
447
452 inline uint ReservedCount() const
453 {
454 return this->action_counts[MTA_LOAD];
455 }
456
461 inline uint UnloadCount() const
462 {
463 return this->action_counts[MTA_TRANSFER] + this->action_counts[MTA_DELIVER];
464 }
465
470 inline uint RemainingCount() const
471 {
472 return this->action_counts[MTA_KEEP] + this->action_counts[MTA_LOAD];
473 }
474
475 void Append(CargoPacket *cp, MoveToAction action = MTA_KEEP);
476
477 void AgeCargo();
478
479 void InvalidateCache();
480
481 bool Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8_t order_flags, const GoodsEntry *ge, CargoID cargo, CargoPayment *payment, TileIndex current_tile);
482
488 inline void KeepAll()
489 {
490 this->action_counts[MTA_DELIVER] = this->action_counts[MTA_TRANSFER] = this->action_counts[MTA_LOAD] = 0;
491 this->action_counts[MTA_KEEP] = this->count;
492 }
493
494 /* Methods for moving cargo around. First parameter is always maximum
495 * amount of cargo to be moved. Second parameter is destination (if
496 * applicable), return value is amount of cargo actually moved. */
497
498 template<MoveToAction Tfrom, MoveToAction Tto>
499 uint Reassign(uint max_move);
500 uint Return(uint max_move, StationCargoList *dest, StationID next_station, TileIndex current_tile);
501 uint Unload(uint max_move, StationCargoList *dest, CargoID cargo, CargoPayment *payment, TileIndex current_tile);
502 uint Shift(uint max_move, VehicleCargoList *dest);
503 uint Truncate(uint max_move = UINT_MAX);
504 uint Reroute(uint max_move, VehicleCargoList *dest, StationID avoid, StationID avoid2, const GoodsEntry *ge);
505
513 static bool AreMergable(const CargoPacket *cp1, const CargoPacket *cp2)
514 {
515 return cp1->source_xy == cp2->source_xy &&
517 cp1->source_type == cp2->source_type &&
518 cp1->first_station == cp2->first_station &&
519 cp1->source_id == cp2->source_id;
520 }
521};
522
524typedef std::map<StationID, uint> StationCargoAmountMap;
525
529class StationCargoList : public CargoList<StationCargoList, StationCargoPacketMap> {
530protected:
533
535
536public:
539 /* So we can use private/protected variables in the saveload code */
540 friend class SlStationGoods;
541
542 friend class CargoLoad;
543 friend class CargoTransfer;
544 template<class Tsource>
545 friend class CargoRemoval;
546 friend class CargoReservation;
547 friend class CargoReturn;
548 friend class StationCargoReroute;
549
550 static void InvalidateAllFrom(SourceType src_type, SourceID src);
551
552 template<class Taction>
553 bool ShiftCargo(Taction &action, StationID next);
554
555 template<class Taction>
556 uint ShiftCargo(Taction action, StationIDStack next, bool include_invalid);
557
558 void Append(CargoPacket *cp, StationID next);
559
565 inline bool HasCargoFor(StationIDStack next) const
566 {
567 while (!next.IsEmpty()) {
568 if (this->packets.find(next.Pop()) != this->packets.end()) return true;
569 }
570 /* Packets for INVALID_STATION can go anywhere. */
571 return this->packets.find(INVALID_STATION) != this->packets.end();
572 }
573
578 inline StationID GetFirstStation() const
579 {
580 return this->count == 0 ? INVALID_STATION : this->packets.begin()->second.front()->first_station;
581 }
582
588 inline uint AvailableCount() const
589 {
590 return this->count;
591 }
592
597 inline uint ReservedCount() const
598 {
599 return this->reserved_count;
600 }
601
607 inline uint TotalCount() const
608 {
609 return this->count + this->reserved_count;
610 }
611
612 /* Methods for moving cargo around. First parameter is always maximum
613 * amount of cargo to be moved. Second parameter is destination (if
614 * applicable), return value is amount of cargo actually moved. */
615
616 uint Reserve(uint max_move, VehicleCargoList *dest, StationIDStack next, TileIndex current_tile);
617 uint Load(uint max_move, VehicleCargoList *dest, StationIDStack next, TileIndex current_tile);
618 uint Truncate(uint max_move = UINT_MAX, StationCargoAmountMap *cargo_per_source = nullptr);
619 uint Reroute(uint max_move, StationCargoList *dest, StationID avoid, StationID avoid2, const GoodsEntry *ge);
620
628 static bool AreMergable(const CargoPacket *cp1, const CargoPacket *cp2)
629 {
630 return cp1->source_xy == cp2->source_xy &&
632 cp1->source_type == cp2->source_type &&
633 cp1->first_station == cp2->first_station &&
634 cp1->source_id == cp2->source_id;
635 }
636};
637
638#endif /* CARGOPACKET_H */
Types related to cargoes...
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:22
uint16_t SourceID
Contains either industry ID, town ID or company ID (or INVALID_SOURCE)
Definition cargo_type.h:143
static const SourceID INVALID_SOURCE
Invalid/unknown index of source.
Definition cargo_type.h:144
SourceType
Types of cargo source and destination.
Definition cargo_type.h:137
@ Industry
Source/destination is an industry.
CargoPacketPool _cargopacket_pool
The actual pool with cargo packets.
uint32_t CargoPacketID
Unique identifier for a single cargo packet.
Definition cargopacket.h:23
SaveLoadTable GetCargoPacketDesc()
Wrapper function to get the CargoPacket's internal structure while some of the variables itself are p...
Pool< CargoPacket, CargoPacketID, 1024, 0xFFF000, PT_NORMAL, true, false > CargoPacketPool
Type of the pool for cargo packets for a little over 16 million packets.
Definition cargopacket.h:27
Action of final delivery of cargo.
Definition cargoaction.h:39
Simple collection class for a list of cargo packets.
Tcont::reverse_iterator ReverseIterator
The reverse iterator for our container.
void OnCleanPool()
Empty the cargo list, but don't free the cargo packets; the cargo packets are cleaned by CargoPacket'...
MoveToAction
Kind of actions that could be done with packets on move.
@ MTA_KEEP
Keep the cargo in the vehicle.
@ MTA_DELIVER
Deliver the cargo to some town or industry.
@ MTA_LOAD
Load the cargo from the station.
@ MTA_TRANSFER
Transfer the cargo to the station.
Tcont packets
The cargo packets in this list.
~CargoList()
Destroy the cargolist ("frees" all cargo packets).
const Tcont * Packets() const
Returns a pointer to the cargo packet list (so you can iterate over it etc).
Tcont::const_iterator ConstIterator
The const iterator for our container.
uint count
Cache for the number of cargo entities.
CargoList()
Create the cargo list.
uint64_t cargo_periods_in_transit
Cache for the sum of number of cargo aging periods in transit of each entity; comparable to man-hours...
static bool TryMerge(CargoPacket *cp, CargoPacket *icp)
Tries to merge the second packet into the first and return if that was successful.
Tcont::iterator Iterator
The iterator for our container.
Tcont::const_reverse_iterator ConstReverseIterator
The const reverse iterator for our container.
uint PeriodsInTransit() const
Returns average number of cargo aging periods in transit for a cargo entity.
void AddToCache(const CargoPacket *cp)
Update the cache to reflect adding of this packet.
void InvalidateCache()
Invalidates the cached data and rebuilds it.
void RemoveFromCache(const CargoPacket *cp, uint count)
Update the cached values to reflect the removal of this packet or part of it.
Action of loading cargo from a station onto a vehicle.
Definition cargoaction.h:83
Abstract action of removing cargo from a vehicle or a station.
Definition cargoaction.h:20
Action of reserving cargo from a station to be loaded onto a vehicle.
Definition cargoaction.h:93
Action of returning previously reserved cargo from the vehicle to the station.
Action of shifting cargo from one vehicle to another.
Action of transferring cargo from a vehicle to a station.
Definition cargoaction.h:73
Hand-rolled multimap as map of lists.
Definition multimap.hpp:281
Minimal stack that uses a pool to avoid pointers.
Titem Pop()
Pop an item from the stack.
bool IsEmpty() const
Check if the stack is empty.
CargoList that is used for stations.
CargoList< StationCargoList, StationCargoPacketMap > Parent
The (direct) parent of this class.
uint TotalCount() const
Returns total count of cargo at the station, including cargo which is already reserved for loading.
uint Reroute(uint max_move, StationCargoList *dest, StationID avoid, StationID avoid2, const GoodsEntry *ge)
Routes packets with station "avoid" as next hop to a different place.
uint ReservedCount() const
Returns sum of cargo reserved for loading onto vehicles.
uint AvailableCount() const
Returns sum of cargo still available for loading at the sation.
void Append(CargoPacket *cp, StationID next)
Appends the given cargo packet to the range of packets with the same next station.
uint Reserve(uint max_move, VehicleCargoList *dest, StationIDStack next, TileIndex current_tile)
Reserves cargo for loading onto the vehicle.
uint Truncate(uint max_move=UINT_MAX, StationCargoAmountMap *cargo_per_source=nullptr)
Truncates where each destination loses roughly the same percentage of its cargo.
bool ShiftCargo(Taction &action, StationID next)
Shifts cargo from the front of the packet list for a specific station and applies some action to it.
uint reserved_count
Amount of cargo being reserved for loading.
static bool AreMergable(const CargoPacket *cp1, const CargoPacket *cp2)
Are the two CargoPackets mergeable in the context of a list of CargoPackets for a Station?
uint Load(uint max_move, VehicleCargoList *dest, StationIDStack next, TileIndex current_tile)
Loads cargo onto a vehicle.
bool HasCargoFor(StationIDStack next) const
Check for cargo headed for a specific station.
StationID GetFirstStation() const
Returns first station of the first cargo packet in this list.
Action of rerouting cargo in a station.
CargoList that is used for vehicles.
uint Shift(uint max_move, VehicleCargoList *dest)
Shifts cargo between two vehicles.
void AddToMeta(const CargoPacket *cp, MoveToAction action)
Adds a packet to the metadata.
uint UnloadCount() const
Returns sum of cargo to be moved out of the vehicle at the current station.
bool Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8_t order_flags, const GoodsEntry *ge, CargoID cargo, CargoPayment *payment, TileIndex current_tile)
Stages cargo for unloading.
void PopCargo(Taction action)
Pops cargo from the back of the packet list and applies some action to it.
Money GetFeederShare() const
Returns total sum of the feeder share for all packets.
uint Reroute(uint max_move, VehicleCargoList *dest, StationID avoid, StationID avoid2, const GoodsEntry *ge)
Routes packets with station "avoid" as next hop to a different place.
uint ActionCount(MoveToAction action) const
Returns the amount of cargo designated for a given purpose.
uint Truncate(uint max_move=UINT_MAX)
Truncates the cargo in this list to the given amount.
uint Unload(uint max_move, StationCargoList *dest, CargoID cargo, CargoPayment *payment, TileIndex current_tile)
Unloads cargo at the given station.
void AssertCountConsistency() const
Assert that the designation counts add up.
void RemoveFromMeta(const CargoPacket *cp, MoveToAction action, uint count)
Removes a packet or part of it from the metadata.
uint Return(uint max_move, StationCargoList *dest, StationID next_station, TileIndex current_tile)
Returns reserved cargo to the station and removes it from the cache.
static bool AreMergable(const CargoPacket *cp1, const CargoPacket *cp2)
Are the two CargoPackets mergeable in the context of a list of CargoPackets for a Vehicle?
uint TotalCount() const
Returns sum of cargo, including reserved cargo.
uint action_counts[NUM_MOVE_TO_ACTION]
Counts of cargo to be transferred, delivered, kept and loaded.
uint ReservedCount() const
Returns sum of reserved cargo.
static MoveToAction ChooseAction(const CargoPacket *cp, StationID cargo_next, StationID current_station, bool accepted, StationIDStack next_station)
Choose action to be performed with the given cargo packet.
uint RemainingCount() const
Returns the sum of cargo to be kept in the vehicle at the current station.
CargoList< VehicleCargoList, CargoPacketList > Parent
The (direct) parent of this class.
Money feeder_share
Cache for the feeder share.
void Append(CargoPacket *cp, MoveToAction action=MTA_KEEP)
Appends the given cargo packet.
void RemoveFromCache(const CargoPacket *cp, uint count)
Update the cached values to reflect the removal of this packet or part of it.
uint Reassign(uint max_move)
Moves some cargo from one designation to another.
void InvalidateCache()
Invalidates the cached data and rebuild it.
void AddToCache(const CargoPacket *cp)
Update the cache to reflect adding of this packet.
void KeepAll()
Marks all cargo in the vehicle as to be kept.
StationID GetFirstStation() const
Returns the first station of the first cargo packet in this list.
void AgeCargo()
Ages the all cargo in this list.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
void ShiftCargo(Taction action)
Shifts cargo from the front of the packet list and applies some action to it.
Action of rerouting cargo staged for transfer in a vehicle.
Types related to the economy.
uint DistanceManhattan(TileIndex t0, TileIndex t1)
Gets the Manhattan distance between the two given tiles.
Definition map.cpp:146
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition map_func.h:425
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
Definition map_func.h:415
constexpr T abs(const T a)
Returns the absolute value of (scalar) variable.
Definition math_func.hpp:23
Multimap with deterministic ordering of items with equal keys.
Types related to orders.
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
Functions/types related to saving and loading games.
std::span< const struct SaveLoad > SaveLoadTable
A table of SaveLoad entries.
Definition saveload.h:515
Types related to stations.
Container for cargo from the same location and time.
Definition cargopacket.h:40
void Reduce(uint count)
Reduce the packet by the given amount and remove the feeder share.
uint16_t Count() const
Gets the number of 'items' in this packet.
Money GetFeederShare(uint part) const
Gets part of the amount of money already paid to earlier vehicles in the feeder chain.
~CargoPacket()
Destroy the packet.
Definition cargopacket.h:82
void Merge(CargoPacket *cp)
Merge another packet into this one.
Money feeder_share
Value of feeder pickup to be paid for on delivery of cargo.
Definition cargopacket.h:51
static const uint16_t MAX_COUNT
Maximum number of items in a single cargo packet.
Definition cargopacket.h:74
TileIndex source_xy
The origin of the cargo.
Definition cargopacket.h:53
void SetNextHop(StationID next_hop)
Sets the station where the packet is supposed to go next.
Definition cargopacket.h:92
SourceID source_id
Index of industry/town/HQ, INVALID_SOURCE if unknown/invalid.
Definition cargopacket.h:56
CargoPacket * Split(uint new_size)
Split this packet in two and return the split off part.
StationID next_hop
Station where the cargo wants to go next.
Definition cargopacket.h:64
void UpdateLoadingTile(TileIndex tile)
Update for the cargo being loaded on this tile.
friend SaveLoadTable GetCargoPacketDesc()
We want this to be saved, right?
void AddFeederShare(Money new_share)
Adds some feeder share to the packet.
SourceID GetSourceID() const
Gets the ID of the cargo's source.
SourceType source_type
Type of source_id.
Definition cargopacket.h:57
static void AfterLoad()
Savegame conversion for cargopackets.
StationID GetNextHop() const
Gets the ID of station the cargo wants to go next.
uint16_t count
The amount of cargo in this packet.
Definition cargopacket.h:48
CargoPacket()
Create a new packet for savegame loading.
Money GetFeederShare() const
Gets the amount of money already paid to earlier vehicles in the feeder chain.
StationID GetFirstStation() const
Gets the ID of the station where the cargo was loaded for the first time.
uint GetDistance(TileIndex current_tile) const
Get the current distance the cargo has traveled.
StationID first_station
The station where the cargo came from first.
Definition cargopacket.h:63
static void InvalidateAllFrom(SourceType src_type, SourceID src)
Invalidates (sets source_id to INVALID_SOURCE) all cargo packets from given source.
Vector travelled
If cargo is in station: the vector from the unload tile to the source tile. If in vehicle: an interme...
Definition cargopacket.h:54
uint16_t GetPeriodsInTransit() const
Gets the number of cargo aging periods this cargo has been in transit.
void UpdateUnloadingTile(TileIndex tile)
Update for the cargo being unloaded on this tile.
SourceType GetSourceType() const
Gets the type of the cargo's source.
uint16_t periods_in_transit
Amount of cargo aging periods this packet has been in transit.
Definition cargopacket.h:49
Helper class to perform the cargo payment.
Stores station stats for a single cargo.
Base class for all PoolItems.
Base class for all pools.
Definition pool_type.hpp:80
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:95
Types related to vehicles.