28#include <SDL_endian.h>
57 value = SDL_SwapLE16(value);
58 memcpy(
expand(
sizeof(uint16_t)), &value,
sizeof(uint16_t));
63 value = SDL_SwapLE32(value);
69 int stringLength =
string.length();
74 length = stringLength;
76 else if (length < stringLength)
79 stringLength = length;
82 char *data =
expand(length);
85 memcpy(data,
string.data(), stringLength);
88 if (length > stringLength)
90 memset(data + stringLength,
'\0', length - stringLength);
105 data[1] |= temp >> 8;
139 data[2] |= direction;
void writeInt32(uint32_t value)
Writes an unsigned 32-bit integer to the message.
static char * expand(size_t size)
Expand the packet data to be able to hold more data.
void writeInt8(uint8_t value)
Writes an unsigned 8-bit integer to the message.
void writeInt16(uint16_t value)
Writes an unsigned 16-bit integer to the message.
void writeString(const std::string &string, int length=-1)
Writes a string.
void writeCoordinates(uint16_t x, uint16_t y, uint8_t direction)
Encodes coordinates and direction in 3 bytes.
static Network * mInstance
void info(const char *log_text,...) LOG_PRINTF_ATTR
Warning: buffers and other variables are shared, so there can be only one connection active at a time...