| 310 | */ |
| 311 | template <class Taction> |
| 312 | void VehicleCargoList::PopCargo(Taction action) |
| 313 | { |
| 314 | if (this->packets.empty()) return; |
| 315 | Iterator it(--(this->packets.end())); |
| 316 | Iterator begin(this->packets.begin()); |
| 317 | while (action.MaxMove() > 0) { |
| 318 | CargoPacket *cp = *it; |
| 319 | if (action(cp)) { |
| 320 | if (it != begin) { |
| 321 | this->packets.erase(it--); |
| 322 | } else { |
| 323 | this->packets.erase(it); |
| 324 | break; |
| 325 | } |
| 326 | } else { |
| 327 | break; |
| 328 | } |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * Update the cached values to reflect the removal of this packet or part of it. |