From 2795ed5b091fa5580976547b3669bac78cd595ce Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 17 Feb 2013 14:10:15 +0000 Subject: (svn r25008) -Codechange: Make CargoList::Truncate behave similarly to CargoList::MoveTo, i.e. pass the amount to truncate (fonsinchen) --- src/cargopacket.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/cargopacket.cpp') 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::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 -void CargoList::Truncate(uint max_remaining) +uint CargoList::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::Truncate(uint max_remaining) } ++it; } + return max_move; } /** -- cgit v1.2.3-70-g09d2