From 8a54e8994a2b47ca32b852d9ed7b9ae003ddfabd Mon Sep 17 00:00:00 2001 From: Cloaked9000 Date: Wed, 21 Dec 2016 17:57:39 +0000 Subject: [PATCH] Fixed read_raw buffer issues (properly this time). Also added '<<' overload on Packet for char* --- include/frnetlib/Packet.h | 9 +++++++++ src/Socket.cpp | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/frnetlib/Packet.h b/include/frnetlib/Packet.h index 69ec162..c5ad648 100644 --- a/include/frnetlib/Packet.h +++ b/include/frnetlib/Packet.h @@ -187,6 +187,15 @@ namespace fr return *this; } + /* + * Adds a char array + */ + inline Packet &operator<<(const char *var) + { + *this << std::string(var); + return *this; + } + /* * Removes a string variable from the packet */ diff --git a/src/Socket.cpp b/src/Socket.cpp index 24375ba..3d3ca61 100644 --- a/src/Socket.cpp +++ b/src/Socket.cpp @@ -82,7 +82,8 @@ namespace fr while(bytes_remaining > 0) { size_t received = 0; - Status status = receive_raw((uintptr_t*)dest + bytes_read, (size_t)bytes_remaining, received); + char *arr = (char*)dest; + Status status = receive_raw(&arr[bytes_read], (size_t)bytes_remaining, received); if(status != fr::Socket::Success) return status; bytes_remaining -= received;