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

Method Recv_bytes

src/network/core/packet.cpp:403–412  ·  view source on GitHub ↗

* Extract at most the length of the span bytes from the packet into the span. * @param destination The span to write the bytes to. * @return The number of bytes that were actually read. */

Source from the content-addressed store, hash-verified

401 * @return The number of bytes that were actually read.
402 */
403size_t Packet::Recv_bytes(std::span<uint8_t> destination)
404{
405 auto transfer_to_span = [&destination](std::span<const uint8_t> source) {
406 auto to_copy = source.subspan(0, destination.size());
407 std::ranges::copy(to_copy, destination.begin());
408 return to_copy.size();
409 };
410
411 return this->TransferOut(transfer_to_span);
412}
413
414/**
415 * Reads characters (bytes) from the packet until it finds a '\0', or reaches a

Callers 5

ReceiveRequestMethod · 0.80
ReceiveResponseMethod · 0.80
Receive_SERVER_INFOMethod · 0.80
DeserializeGRFIdentifierFunction · 0.80

Calls 4

TransferOutMethod · 0.95
copyFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected