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:
QAston
2014-01-30 23:43:10 +01:00
parent 856e0933b5
commit 9495194bf2
2 changed files with 10 additions and 6 deletions

View File

@@ -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);

View File

@@ -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