mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 10:05:32 +01:00
Fix warnings introduced on littleendian in 2134cb610d
This fix prevents possible issues on bigendian machines. Don't use c style casts ppl, it's evul.
This commit is contained in:
@@ -321,7 +321,7 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||
|
||||
socket().recv((char *)&buf[0], 4);
|
||||
|
||||
EndianConvert(*((uint16*)(buf[0])));
|
||||
EndianConvertPtr<uint16>(&buf[0]);
|
||||
|
||||
uint16 remaining = ((sAuthLogonChallenge_C *)&buf[0])->size;
|
||||
TC_LOG_DEBUG("server.authserver", "[AuthChallenge] got header, body is %#04x bytes", remaining);
|
||||
@@ -341,11 +341,11 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||
|
||||
// BigEndian code, nop in little endian case
|
||||
// size already converted
|
||||
EndianConvert(*((uint32*)(&ch->gamename[0])));
|
||||
EndianConvertPtr<uint32>(&ch->gamename[0]);
|
||||
EndianConvert(ch->build);
|
||||
EndianConvert(*((uint32*)(&ch->platform[0])));
|
||||
EndianConvert(*((uint32*)(&ch->os[0])));
|
||||
EndianConvert(*((uint32*)(&ch->country[0])));
|
||||
EndianConvertPtr<uint32>(&ch->platform[0]);
|
||||
EndianConvertPtr<uint32>(&ch->os[0]);
|
||||
EndianConvertPtr<uint32>(&ch->country[0]);
|
||||
EndianConvert(ch->timezone_bias);
|
||||
EndianConvert(ch->ip);
|
||||
|
||||
@@ -779,7 +779,7 @@ bool AuthSocket::_HandleReconnectChallenge()
|
||||
|
||||
socket().recv((char *)&buf[0], 4);
|
||||
|
||||
EndianConvert(*((uint16*)(buf[0])));
|
||||
EndianConvertPtr<uint16>(&buf[0]);
|
||||
|
||||
uint16 remaining = ((sAuthLogonChallenge_C *)&buf[0])->size;
|
||||
TC_LOG_DEBUG("server.authserver", "[ReconnectChallenge] got header, body is %#04x bytes", remaining);
|
||||
|
||||
@@ -47,9 +47,13 @@ namespace ByteConverter
|
||||
#if TRINITY_ENDIAN == TRINITY_BIGENDIAN
|
||||
template<typename T> inline void EndianConvert(T& val) { ByteConverter::apply<T>(&val); }
|
||||
template<typename T> inline void EndianConvertReverse(T&) { }
|
||||
template<typename T> inline void EndianConvertPtr(void* val) { ByteConverter::apply<T>(val); }
|
||||
template<typename T> inline void EndianConvertPtrReverse(void*) { }
|
||||
#else
|
||||
template<typename T> inline void EndianConvert(T&) { }
|
||||
template<typename T> inline void EndianConvertReverse(T& val) { ByteConverter::apply<T>(&val); }
|
||||
template<typename T> inline void EndianConvertPtr(void*) { }
|
||||
template<typename T> inline void EndianConvertPtrReverse(void* val) { ByteConverter::apply<T>(val); }
|
||||
#endif
|
||||
|
||||
template<typename T> void EndianConvert(T*); // will generate link error
|
||||
|
||||
Reference in New Issue
Block a user