Update for latest nazarautils

This commit is contained in:
SirLynix
2023-09-08 09:10:22 +02:00
parent aef8b01f15
commit 1009b296a1
13 changed files with 174 additions and 189 deletions

View File

@@ -129,7 +129,7 @@ namespace Nz
context.FlushBits();
if (context.endianness != Endianness::Unknown && context.endianness != GetPlatformEndianness())
SwapBytes(&value, sizeof(T));
value = ByteSwap(value);
return context.stream->Write(&value, sizeof(T)) == sizeof(T);
}
@@ -208,7 +208,7 @@ namespace Nz
if (context.stream->Read(value, sizeof(T)) == sizeof(T))
{
if (context.endianness != Endianness::Unknown && context.endianness != GetPlatformEndianness())
SwapBytes(value, sizeof(T));
*value = ByteSwap(*value);
return true;
}

View File

@@ -10,8 +10,6 @@
#include <NazaraUtils/Prerequisites.hpp>
#include <Nazara/Network/Config.hpp>
#include <Nazara/Network/Enums.hpp>
#include <functional>
#include <tuple>
#include <type_traits>
namespace Nz

View File

@@ -10,21 +10,13 @@ namespace Nz
template<typename T>
std::enable_if_t<std::is_arithmetic<T>::value, T> HostToNet(T value)
{
#ifdef NAZARA_LITTLE_ENDIAN
return SwapBytes(value);
#else
return value;
#endif
return HostToBigEndian(value);
}
template<typename T>
std::enable_if_t<std::is_arithmetic<T>::value, T> NetToHost(T value)
{
#ifdef NAZARA_LITTLE_ENDIAN
return SwapBytes(value);
#else
return value;
#endif
return BigEndianToHost(value);
}
}