From ec1f0f4c930a600af2ef09cb5fa23d5edfc55ee5 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Sat, 21 Aug 2021 17:28:31 +0200 Subject: [PATCH] Use memcpy for reading and writing SaveBufs --- src/save/SaveBuf.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/save/SaveBuf.h b/src/save/SaveBuf.h index d0817e9a..82381f64 100644 --- a/src/save/SaveBuf.h +++ b/src/save/SaveBuf.h @@ -32,7 +32,7 @@ template inline void ReadSaveBuf(T *out, uint8 *&buf) { - *out = *(T *)buf; + memcpy(out, buf, sizeof(T)); SkipSaveBuf(buf, sizeof(T)); } @@ -40,7 +40,7 @@ template inline void ReadSaveBuf(T *out, uint8 *&buf, uint32 &length) { - *out = *(T *)buf; + memcpy(out, buf, sizeof(T)); SkipSaveBuf(buf, length, sizeof(T)); } @@ -48,8 +48,8 @@ template inline T * WriteSaveBuf(uint8 *&buf, const T &value) { - T *p = (T*)buf; - *p = value; + memcpy(buf, &value, sizeof(T)); + T* p = (T*)buf; SkipSaveBuf(buf, sizeof(T)); return p; } @@ -58,8 +58,8 @@ template inline T * WriteSaveBuf(uint8 *&buf, uint32 &length, const T &value) { - T *p = (T*)buf; - *p = value; + memcpy(buf, &value, sizeof(T)); + T* p = (T*)buf; SkipSaveBuf(buf, length, sizeof(T)); return p; }