summaryrefslogtreecommitdiffstats
path: root/src/Net/Packets/ErrorPacket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Net/Packets/ErrorPacket.cpp')
-rw-r--r--src/Net/Packets/ErrorPacket.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Net/Packets/ErrorPacket.cpp b/src/Net/Packets/ErrorPacket.cpp
index 2a72415..28d364a 100644
--- a/src/Net/Packets/ErrorPacket.cpp
+++ b/src/Net/Packets/ErrorPacket.cpp
@@ -18,6 +18,7 @@
*/
#include "ErrorPacket.h"
+#include <cstring>
namespace Mad {
namespace Net {
@@ -26,18 +27,22 @@ namespace Packets {
ErrorPacket::ErrorPacket(Type type, uint16_t requestId, const Common::Exception &exception)
: Packet(type, requestId)
{
- setLength(sizeof(ErrorData));
+ setLength(sizeof(ErrorData) + exception.getWhere().length());
errorData = (ErrorData*)&rawData->data;
errorData->errorCode = htonl(exception.getErrorCode());
errorData->subCode = htonl(exception.getSubCode());
errorData->subSubCode = htonl(exception.getSubSubCode());
+
+ std::memcpy(errorData->where, exception.getWhere().c_str(), exception.getWhere().length());
}
ErrorPacket& ErrorPacket::operator=(const Packet &p) {
Packet::operator=(p);
- setLength(sizeof(ErrorData));
+ if(getLength() < sizeof(ErrorData))
+ setLength(sizeof(ErrorData));
+
errorData = (ErrorData*)&rawData->data;
return *this;