OpenTTD Source 20241224-master-gf74b0cf984
|
Read some packets, and when do use that data as initial load filter. More...
Public Member Functions | |
PacketReader () | |
Initialise everything. | |
void | AddPacket (Packet &p) |
Add a packet to this buffer. | |
size_t | Read (uint8_t *rbuf, size_t size) override |
Read a given number of bytes from the savegame. | |
void | Reset () override |
Reset this filter to read from the beginning of the file. | |
Public Member Functions inherited from LoadFilter | |
LoadFilter (std::shared_ptr< LoadFilter > chain) | |
Initialise this filter. | |
virtual | ~LoadFilter ()=default |
Make sure the writers are properly closed. | |
Static Public Member Functions | |
static ssize_t | TransferOutMemCopy (PacketReader *destination, const char *source, size_t amount) |
Simple wrapper around fwrite to be able to pass it to Packet's TransferOut. | |
Data Fields | |
std::vector< uint8_t * > | blocks |
Buffer with blocks of allocated memory. | |
uint8_t * | buf |
Buffer we're going to write to/read from. | |
uint8_t * | bufe |
End of the buffer we write to/read from. | |
uint8_t ** | block |
The block we're reading from/writing to. | |
size_t | written_bytes |
The total number of bytes we've written. | |
size_t | read_bytes |
The total number of read bytes. | |
Data Fields inherited from LoadFilter | |
std::shared_ptr< LoadFilter > | chain |
Chained to the (savegame) filters. | |
Static Public Attributes | |
static const size_t | CHUNK = 32 * 1024 |
32 KiB chunks of memory. | |
Read some packets, and when do use that data as initial load filter.
Definition at line 43 of file network_client.cpp.
|
inline |
Initialise everything.
Definition at line 54 of file network_client.cpp.
|
inlineoverride |
Definition at line 58 of file network_client.cpp.
|
inline |
Add a packet to this buffer.
p | The packet to add. |
Definition at line 84 of file network_client.cpp.
References CHUNK, Packet::RemainingBytesToTransfer(), TransferOutMemCopy(), and Packet::TransferOutWithLimit().
|
inlineoverridevirtual |
Read a given number of bytes from the savegame.
buf | The bytes to read. |
len | The number of bytes to read. |
Implements LoadFilter.
Definition at line 99 of file network_client.cpp.
References CHUNK.
|
inlineoverridevirtual |
Reset this filter to read from the beginning of the file.
Reimplemented from LoadFilter.
Definition at line 121 of file network_client.cpp.
References CHUNK.
|
inlinestatic |
Simple wrapper around fwrite to be able to pass it to Packet's TransferOut.
destination | The reader to add the data to. |
source | The buffer to read data from. |
amount | The number of bytes to copy. |
Definition at line 72 of file network_client.cpp.
References buf, and written_bytes.
Referenced by AddPacket().
uint8_t** PacketReader::block |
The block we're reading from/writing to.
Definition at line 49 of file network_client.cpp.
std::vector<uint8_t *> PacketReader::blocks |
Buffer with blocks of allocated memory.
Definition at line 46 of file network_client.cpp.
uint8_t* PacketReader::buf |
Buffer we're going to write to/read from.
Definition at line 47 of file network_client.cpp.
Referenced by TransferOutMemCopy().
uint8_t* PacketReader::bufe |
End of the buffer we write to/read from.
Definition at line 48 of file network_client.cpp.
|
static |
32 KiB chunks of memory.
Definition at line 44 of file network_client.cpp.
Referenced by AddPacket(), Read(), and Reset().
size_t PacketReader::read_bytes |
The total number of read bytes.
Definition at line 51 of file network_client.cpp.
size_t PacketReader::written_bytes |
The total number of bytes we've written.
Definition at line 50 of file network_client.cpp.
Referenced by TransferOutMemCopy().