14 #ifndef NETWORK_CORE_PACKET_H 15 #define NETWORK_CORE_PACKET_H 19 #include "../../string_type.h" Internal entity of a packet.
uint32 Recv_uint32()
Read a 32 bits integer from the packet.
PacketSize pos
The current read/write position in the packet.
void PrepareToSend()
Writes the packet size from the raw packet from packet->size.
void Send_string(const char *data)
Sends a string over the network.
uint8 PacketType
Identifier for the packet.
void Send_uint8(uint8 data)
Package a 8 bits integer in the packet.
Base for all network types (UDP and TCP)
void Send_uint32(uint32 data)
Package a 32 bits integer in the packet.
bool CanReadFromPacket(uint bytes_to_read)
Is it safe to read from the packet, i.e.
Configuration options of the network stuff.
StringValidationSettings
Settings for the string validation.
void PrepareToRead()
Prepares the packet so it can be read.
void Send_uint64(uint64 data)
Package a 64 bits integer in the packet.
byte * buffer
The buffer of this packet, of basically variable length up to SEND_MTU.
void Send_uint16(uint16 data)
Package a 16 bits integer in the packet.
~Packet()
Free the buffer of this packet.
PacketSize size
The size of the whole packet for received packets.
bool Recv_bool()
Read a boolean from the packet.
Packet * next
The next packet.
NetworkSocketHandler * cs
Socket we're associated with.
Packet(NetworkSocketHandler *cs)
Create a packet that is used to read from a network socket.
uint8 Recv_uint8()
Read a 8 bits integer from the packet.
uint64 Recv_uint64()
Read a 64 bits integer from the packet.
Replace the unknown/bad bits with question marks.
void ReadRawPacketSize()
Reads the packet size from the raw packet and stores it in the packet->size.
uint16 Recv_uint16()
Read a 16 bits integer from the packet.
void Send_bool(bool data)
Package a boolean in the packet.
uint16 PacketSize
Size of the whole packet.
SocketHandler for all network sockets in OpenTTD.
void Recv_string(char *buffer, size_t size, StringValidationSettings settings=SVS_REPLACE_WITH_QUESTION_MARK)
Reads a string till it finds a '\0' in the stream.