summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-10-18 14:30:37 +0000
committerrubidium <rubidium@openttd.org>2009-10-18 14:30:37 +0000
commitf76de82679ba51aa95c529201ecf3cfc4be01ae9 (patch)
treee2a328bd6034f49df52bde239369b96741157502 /src
parent138e7233bce5ff5a9d20f54af80f6104303d6ca0 (diff)
downloadopenttd-f76de82679ba51aa95c529201ecf3cfc4be01ae9.tar.xz
(svn r17801) -Codechange: for StationCargoLists the 'loaded_at_xy' does not matter when merging CargoPackets
Diffstat (limited to 'src')
-rw-r--r--src/cargopacket.cpp2
-rw-r--r--src/cargopacket.h45
2 files changed, 32 insertions, 15 deletions
diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp
index f37df719a..313e7db4f 100644
--- a/src/cargopacket.cpp
+++ b/src/cargopacket.cpp
@@ -111,7 +111,7 @@ void CargoList<Tinst>::Append(CargoPacket *cp)
for (List::iterator it = this->packets.begin(); it != this->packets.end(); it++) {
CargoPacket *icp = *it;
- if (icp->SameSource(cp) && icp->count + cp->count <= CargoPacket::MAX_COUNT) {
+ if (Tinst::AreMergable(icp, cp) && icp->count + cp->count <= CargoPacket::MAX_COUNT) {
icp->count += cp->count;
icp->feeder_share += cp->feeder_share;
diff --git a/src/cargopacket.h b/src/cargopacket.h
index e7df9afdc..a29a1ff22 100644
--- a/src/cargopacket.h
+++ b/src/cargopacket.h
@@ -115,20 +115,6 @@ public:
}
- /**
- * Checks whether the cargo packet is from (exactly) the same source
- * in time and location.
- * @param cp the cargo packet to compare to
- * @return true if and only if days_in_transit and source_xy are equal
- */
- FORCEINLINE bool SameSource(const CargoPacket *cp) const
- {
- return this->source_xy == cp->source_xy &&
- this->days_in_transit == cp->days_in_transit &&
- this->source_type == cp->source_type &&
- this->source_id == cp->source_id;
- }
-
static void InvalidateAllFrom(SourceType src_type, SourceID src);
};
@@ -301,6 +287,22 @@ public:
* Ages the all cargo in this list
*/
void AgeCargo();
+
+ /**
+ * Are two the two CargoPackets mergeable in the context of
+ * a list of CargoPackets for a Vehicle?
+ * @param cp1 the first CargoPacket
+ * @param cp2 the second CargoPacket
+ * @return true if they are mergeable
+ */
+ static bool AreMergable(const CargoPacket *cp1, const CargoPacket *cp2)
+ {
+ return cp1->source_xy == cp2->source_xy &&
+ cp1->days_in_transit == cp2->days_in_transit &&
+ cp1->source_type == cp2->source_type &&
+ cp1->source_id == cp2->source_id &&
+ cp1->loaded_at_xy == cp2->loaded_at_xy;
+ }
};
/**
@@ -310,6 +312,21 @@ class StationCargoList : public CargoList<StationCargoList> {
public:
/** The stations, via GoodsEntry, have a CargoList. */
friend const struct SaveLoad *GetGoodsDesc();
+
+ /**
+ * Are two the two CargoPackets mergeable in the context of
+ * a list of CargoPackets for a Vehicle?
+ * @param cp1 the first CargoPacket
+ * @param cp2 the second CargoPacket
+ * @return true if they are mergeable
+ */
+ static bool AreMergable(const CargoPacket *cp1, const CargoPacket *cp2)
+ {
+ return cp1->source_xy == cp2->source_xy &&
+ cp1->days_in_transit == cp2->days_in_transit &&
+ cp1->source_type == cp2->source_type &&
+ cp1->source_id == cp2->source_id;
+ }
};
#endif /* CARGOPACKET_H */