diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2014-05-19 17:56:22 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2014-05-19 17:56:22 -0700 |
commit | 42a46737d480c997e6f6ebbf57e1c8f3b56ac940 (patch) | |
tree | 53bd842c0ef7071b06faad51de5813a9e4f4efb5 /src | |
parent | 630782d8c6e7bdd9cc1d5b1d0f49836752f9228b (diff) | |
download | tmwa-42a46737d480c997e6f6ebbf57e1c8f3b56ac940.tar.gz tmwa-42a46737d480c997e6f6ebbf57e1c8f3b56ac940.tar.bz2 tmwa-42a46737d480c997e6f6ebbf57e1c8f3b56ac940.tar.xz tmwa-42a46737d480c997e6f6ebbf57e1c8f3b56ac940.zip |
Fix a couple of real bugs and also some gcc 4.7 compatibility
Diffstat (limited to 'src')
-rw-r--r-- | src/ints/little.hpp | 12 | ||||
-rw-r--r-- | src/login/login.cpp | 4 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/ints/little.hpp b/src/ints/little.hpp index 68f8683..9dd32c2 100644 --- a/src/ints/little.hpp +++ b/src/ints/little.hpp @@ -33,6 +33,14 @@ namespace ints { + // gcc doesn't always provide a builtin for this, + // but it *does* optimize hand-written ones + constexpr + uint16_t bswap16(uint16_t v) + { + return v >> 8 | v << 8; + } + // TODO hoist this to byte.hpp and also implement big.hpp struct Byte { @@ -64,7 +72,7 @@ namespace ints bool native_to_network(Little16 *net, uint16_t nat) { if (__BYTE_ORDER == __BIG_ENDIAN) - nat = __builtin_bswap16(nat); + nat = bswap16(nat); __builtin_memcpy(net, &nat, 2); return true; } @@ -97,7 +105,7 @@ namespace ints uint16_t tmp; __builtin_memcpy(&tmp, &net, 2); if (__BYTE_ORDER == __BIG_ENDIAN) - tmp = __builtin_bswap16(tmp); + tmp = bswap16(tmp); *nat = tmp; return true; } diff --git a/src/login/login.cpp b/src/login/login.cpp index 3f91025..d553d7c 100644 --- a/src/login/login.cpp +++ b/src/login/login.cpp @@ -1918,7 +1918,7 @@ void parse_admin(Session *s) fixed_37.account_id = AccountId(); AccountName account_name = stringish<AccountName>(fixed.account_name.to_print()); int statut = fixed.status; - timestamp_seconds_buffer error_message = stringish<timestamp_seconds_buffer>(error_message.to_print()); + timestamp_seconds_buffer error_message = stringish<timestamp_seconds_buffer>(fixed.error_message.to_print()); if (statut != 7 || !error_message) { // 7: // 6 = Your are Prohibited to log in until %s @@ -2316,7 +2316,7 @@ void parse_admin(Session *s) SPacket_0x7945_Fixed fixed_45; fixed_45.account_id = AccountId(); - AccountName account_name = stringish<AccountName>(account_name.to_print()); + AccountName account_name = stringish<AccountName>(fixed.account_name.to_print()); const AuthData *ad = search_account(account_name); if (ad) { |