Index: src/network/network_udp.cpp =================================================================== --- src/network/network_udp.cpp (revision 11719) +++ src/network/network_udp.cpp (arbetskopia) @@ -19,7 +19,6 @@ #include "network_udp.h" #include "../variables.h" #include "../newgrf_config.h" -#include "../core/endian_func.hpp" #include "core/udp.h" @@ -334,14 +333,27 @@ /* packet begins with the protocol version (uint8) * then an uint16 which indicates how many * ip:port pairs are in this packet, after that - * an uint32 (ip) and an uint16 (port) for each pair + * an uint32 (ip, network byte order) and an uint16 + * (port, little-endian) for each pair */ ver = p->Recv_uint8(); if (ver == 1) { for (i = p->Recv_uint16(); i != 0 ; i--) { - ip.s_addr = TO_LE32(p->Recv_uint32()); + /* the ip adress is sent in the network byte order on + * the wire, even though everything else is sent as + * little-endian. To copy from the packet, storing + * it in the same byte order in memory, we just copy + * byte for byte. Using recv_uint32 would cause a + * byte swap on a big-endian machine. + */ + uint8 *ptr = (uint8 *) &ip.s_addr; + ptr[0] = p->Recv_uint8(); + ptr[1] = p->Recv_uint8(); + ptr[2] = p->Recv_uint8(); + ptr[3] = p->Recv_uint8(); + port = p->Recv_uint16(); /* Somehow we reached the end of the packet */