Use memcpy for reading and writing SaveBufs

This commit is contained in:
GaryOderNichts 2021-08-21 17:28:31 +02:00
parent 58e725bd03
commit ec1f0f4c93

View File

@ -32,7 +32,7 @@ template<typename T>
inline void
ReadSaveBuf(T *out, uint8 *&buf)
{
*out = *(T *)buf;
memcpy(out, buf, sizeof(T));
SkipSaveBuf(buf, sizeof(T));
}
@ -40,7 +40,7 @@ template<typename T>
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<typename T>
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<typename T>
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;
}