summaryrefslogtreecommitdiff
path: root/src/cargopacket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cargopacket.cpp')
-rw-r--r--src/cargopacket.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp
index 0b92de0c8..0603d9125 100644
--- a/src/cargopacket.cpp
+++ b/src/cargopacket.cpp
@@ -209,11 +209,14 @@ void CargoList<Tinst>::Append(CargoPacket *cp)
/**
* Truncates the cargo in this list to the given amount. It leaves the
* first count cargo entities and removes the rest.
- * @param max_remaining Maximum amount of entities to be in the list after the command.
+ * @param max_move Maximum amount of entities to be removed from the list.
+ * @return Amount of entities actually moved.
*/
template <class Tinst>
-void CargoList<Tinst>::Truncate(uint max_remaining)
+uint CargoList<Tinst>::Truncate(uint max_move)
{
+ max_move = min(this->count, max_move);
+ uint max_remaining = this->count - max_move;
for (Iterator it(packets.begin()); it != packets.end(); /* done during loop*/) {
CargoPacket *cp = *it;
if (max_remaining == 0) {
@@ -236,6 +239,7 @@ void CargoList<Tinst>::Truncate(uint max_remaining)
}
++it;
}
+ return max_move;
}
/**