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

Method Recv_buffer

src/network/core/packet.cpp:385–396  ·  view source on GitHub ↗

* Extract a sized byte buffer from the packet. * @return The extracted buffer. */

Source from the content-addressed store, hash-verified

383 * @return The extracted buffer.
384 */
385std::vector<uint8_t> Packet::Recv_buffer()
386{
387 uint16_t size = this->Recv_uint16();
388 if (size == 0 || !this->CanReadFromPacket(size, true)) return {};
389
390 std::vector<uint8_t> data;
391 while (size-- > 0) {
392 data.push_back(this->buffer[this->pos++]);
393 }
394
395 return data;
396}
397
398/**
399 * Extract at most the length of the span bytes from the packet into the span.

Callers 1

ReceiveCommandMethod · 0.80

Calls 3

Recv_uint16Method · 0.95
CanReadFromPacketMethod · 0.95
push_backMethod · 0.80

Tested by

no test coverage detected