1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2025-12-23 21:22:46 +01:00

Codechange: put SourceType and SourceID into Source struct

This commit is contained in:
Rubidium
2025-02-05 20:15:11 +01:00
committed by rubidium42
parent 95bfd68341
commit 5f41bc0279
20 changed files with 180 additions and 199 deletions

View File

@@ -26,8 +26,6 @@ INSTANTIATE_POOL_METHODS(CargoPacket)
*/
CargoPacket::CargoPacket()
{
this->source_type = SourceType::Industry;
this->source_id = INVALID_SOURCE;
}
/**
@@ -35,14 +33,12 @@ CargoPacket::CargoPacket()
*
* @param first_station Source station of the packet.
* @param count Number of cargo entities to put in this packet.
* @param source_type 'Type' of source the packet comes from (for subsidies).
* @param source_id Actual source of the packet (for subsidies).
* @param source Source of the packet (for subsidies).
* @pre count != 0
*/
CargoPacket::CargoPacket(StationID first_station,uint16_t count, SourceType source_type, SourceID source_id) :
CargoPacket::CargoPacket(StationID first_station,uint16_t count, Source source) :
count(count),
source_id(source_id),
source_type(source_type),
source(source),
first_station(first_station)
{
assert(count != 0);
@@ -80,8 +76,7 @@ CargoPacket::CargoPacket(uint16_t count, Money feeder_share, CargoPacket &origin
feeder_share(feeder_share),
source_xy(original.source_xy),
travelled(original.travelled),
source_id(original.source_id),
source_type(original.source_type),
source(original.source),
#ifdef WITH_ASSERT
in_vehicle(original.in_vehicle),
#endif /* WITH_ASSERT */
@@ -134,10 +129,10 @@ void CargoPacket::Reduce(uint count)
* @param src_type Type of source.
* @param src Index of source.
*/
/* static */ void CargoPacket::InvalidateAllFrom(SourceType src_type, SourceID src)
/* static */ void CargoPacket::InvalidateAllFrom(Source src)
{
for (CargoPacket *cp : CargoPacket::Iterate()) {
if (cp->source_type == src_type && cp->source_id == src) cp->source_id = INVALID_SOURCE;
if (cp->source == src) cp->source.id = INVALID_SOURCE;
}
}