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

Method Split

src/cargopacket.cpp:94–103  ·  view source on GitHub ↗

* Split this packet in two and return the split off part. * @param new_size Size of the split part. * @return Split off part, or nullptr if no packet could be allocated! */

Source from the content-addressed store, hash-verified

92 * @return Split off part, or nullptr if no packet could be allocated!
93 */
94CargoPacket *CargoPacket::Split(uint new_size)
95{
96 if (!CargoPacket::CanAllocateItem()) return nullptr;
97
98 Money fs = this->GetFeederShare(new_size);
99 CargoPacket *cp_new = new CargoPacket(new_size, fs, *this);
100 this->feeder_share -= fs;
101 this->count -= new_size;
102 return cp_new;
103}
104
105/**
106 * Merge another packet into this one.

Callers 2

MTA_TRANSFER>Method · 0.80
PreprocessMethod · 0.80

Calls 1

GetFeederShareMethod · 0.95

Tested by

no test coverage detected