MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / PopCargo

Method PopCargo

src/cargopacket.cpp:312–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310 */
311template <class Taction>
312void 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.

Callers 3

ReturnMethod · 0.95
ShiftMethod · 0.95
TruncateMethod · 0.95

Calls 5

emptyMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
MaxMoveMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected