Update to 1.10.0-beta1

This commit is contained in:
dP
2019-10-31 22:24:28 +03:00
parent b84a475e14
commit 599ccf0c2b
1470 changed files with 354219 additions and 16795 deletions

View File

@@ -11,8 +11,6 @@
* @file packet.cpp Basic functions to create, fill and read packets.
*/
#ifdef ENABLE_NETWORK
#include "../../stdafx.h"
#include "../../string_func.h"
@@ -26,10 +24,10 @@
*/
Packet::Packet(NetworkSocketHandler *cs)
{
assert(cs != NULL);
assert(cs != nullptr);
this->cs = cs;
this->next = NULL;
this->next = nullptr;
this->pos = 0; // We start reading from here
this->size = 0;
this->buffer = MallocT<byte>(SEND_MTU);
@@ -41,8 +39,8 @@ Packet::Packet(NetworkSocketHandler *cs)
*/
Packet::Packet(PacketType type)
{
this->cs = NULL;
this->next = NULL;
this->cs = nullptr;
this->next = nullptr;
/* Skip the size so we can write that in before sending the packet */
this->pos = 0;
@@ -64,7 +62,7 @@ Packet::~Packet()
*/
void Packet::PrepareToSend()
{
assert(this->cs == NULL && this->next == NULL);
assert(this->cs == nullptr && this->next == nullptr);
this->buffer[0] = GB(this->size, 0, 8);
this->buffer[1] = GB(this->size, 8, 8);
@@ -151,7 +149,7 @@ void Packet::Send_uint64(uint64 data)
*/
void Packet::Send_string(const char *data)
{
assert(data != NULL);
assert(data != nullptr);
/* The <= *is* valid due to the fact that we are comparing sizes and not the index. */
assert(this->size + strlen(data) + 1 <= SEND_MTU);
while ((this->buffer[this->size++] = *data++) != '\0') {}
@@ -189,7 +187,7 @@ bool Packet::CanReadFromPacket(uint bytes_to_read)
*/
void Packet::ReadRawPacketSize()
{
assert(this->cs != NULL && this->next == NULL);
assert(this->cs != nullptr && this->next == nullptr);
this->size = (PacketSize)this->buffer[0];
this->size += (PacketSize)this->buffer[1] << 8;
}
@@ -310,5 +308,3 @@ void Packet::Recv_string(char *buffer, size_t size, StringValidationSettings set
str_validate(bufp, last, settings);
}
#endif /* ENABLE_NETWORK */