summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-10-18 17:26:10 +0000
committerrubidium <rubidium@openttd.org>2009-10-18 17:26:10 +0000
commit62a6e9509b9067443899afcf8791e97d48aa8983 (patch)
tree4c288501328daf29cc914d608289b75efa642973 /src
parent41037308c09239e901c6160b31292af2eab2f918 (diff)
downloadopenttd-62a6e9509b9067443899afcf8791e97d48aa8983.tar.xz
(svn r17804) -Codechange: move the CargoPacket 'invalidation' when stations get removed to CargoPacket.
Diffstat (limited to 'src')
-rw-r--r--src/cargopacket.cpp12
-rw-r--r--src/cargopacket.h1
-rw-r--r--src/station.cpp6
3 files changed, 14 insertions, 5 deletions
diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp
index 313e7db4f..e9b3f5064 100644
--- a/src/cargopacket.cpp
+++ b/src/cargopacket.cpp
@@ -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
diff --git a/src/cargopacket.h b/src/cargopacket.h
index a29a1ff22..ee0e2163a 100644
--- a/src/cargopacket.h
+++ b/src/cargopacket.h
@@ -116,6 +116,7 @@ public:
static void InvalidateAllFrom(SourceType src_type, SourceID src);
+ static void InvalidateAllFrom(StationID sid);
};
/**
diff --git a/src/station.cpp b/src/station.cpp
index 1ac0341c0..ba0020c73 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -97,11 +97,7 @@ Station::~Station()
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);
}