Mercurial > hg > openttd
changeset 13295:a5fafe76e3f8 draft
(svn r17804) -Codechange: move the CargoPacket 'invalidation' when stations get removed to CargoPacket.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 18 Oct 2009 17:26:10 +0000 |
parents | d7e576abb5d0 |
children | 8d2363c9c7af |
files | src/cargopacket.cpp src/cargopacket.h src/station.cpp |
diffstat | 3 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/cargopacket.cpp +++ b/src/cargopacket.cpp @@ -62,6 +62,18 @@ } } +/** + * 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
--- a/src/cargopacket.h +++ b/src/cargopacket.h @@ -116,6 +116,7 @@ static void InvalidateAllFrom(SourceType src_type, SourceID src); + static void InvalidateAllFrom(StationID sid); }; /**
--- a/src/station.cpp +++ b/src/station.cpp @@ -97,11 +97,7 @@ this->goods[c].cargo.Truncate(0); } - CargoPacket *cp; - FOR_ALL_CARGOPACKETS(cp) { - /* Don't allow cargo packets with invalid source station */ - if (cp->source == this->index) cp->source = INVALID_STATION; - } + CargoPacket::InvalidateAllFrom(this->index); }