* 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! */
| 92 | * @return Split off part, or nullptr if no packet could be allocated! |
| 93 | */ |
| 94 | CargoPacket *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. |
no test coverage detected