mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r17804) -Codechange: move the CargoPacket 'invalidation' when stations get removed to CargoPacket.
This commit is contained in:
parent
41037308c0
commit
62a6e9509b
|
@ -62,6 +62,18 @@ CargoPacket::CargoPacket(uint16 count, byte days_in_transit, Money feeder_share,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidates (sets source to INVALID_STATION) all cargo packets from given station
|
||||||
|
* @param sid the station that gets removed
|
||||||
|
*/
|
||||||
|
/* static */ void CargoPacket::InvalidateAllFrom(StationID sid)
|
||||||
|
{
|
||||||
|
CargoPacket *cp;
|
||||||
|
FOR_ALL_CARGOPACKETS(cp) {
|
||||||
|
if (cp->source == sid) cp->source_id = INVALID_SOURCE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Cargo list implementation
|
* Cargo list implementation
|
||||||
|
|
|
@ -116,6 +116,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
static void InvalidateAllFrom(SourceType src_type, SourceID src);
|
static void InvalidateAllFrom(SourceType src_type, SourceID src);
|
||||||
|
static void InvalidateAllFrom(StationID sid);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -97,11 +97,7 @@ Station::~Station()
|
||||||
this->goods[c].cargo.Truncate(0);
|
this->goods[c].cargo.Truncate(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CargoPacket *cp;
|
CargoPacket::InvalidateAllFrom(this->index);
|
||||||
FOR_ALL_CARGOPACKETS(cp) {
|
|
||||||
/* Don't allow cargo packets with invalid source station */
|
|
||||||
if (cp->source == this->index) cp->source = INVALID_STATION;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue