diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/cbasetypes.h | 2 | ||||
-rw-r--r-- | src/common/socket.c | 7 | ||||
-rw-r--r-- | src/common/socket.h | 1 |
3 files changed, 9 insertions, 1 deletions
diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index c066c1ebd..ae6430a62 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -291,7 +291,7 @@ typedef char bool; ////////////////////////////////////////////////////////////////////////// // Has to be unsigned to avoid problems in some systems -// Problems arise when these functions expect an argument in the range [0,256[ and are feed a signed char. +// Problems arise when these functions expect an argument in the range [0,256[ and are fed a signed char. #include <ctype.h> #define ISALNUM(c) (isalnum((unsigned char)(c))) #define ISALPHA(c) (isalpha((unsigned char)(c))) diff --git a/src/common/socket.c b/src/common/socket.c index f8bdcdc7a..f406a0eea 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -1117,3 +1117,10 @@ uint32 str2ip(const char* ip_str) { return ntohl(inet_addr(ip_str)); } + +// Reorders bytes from network to little endian (Windows). +// Neccessary for sending port numbers to the RO client until Gravity notices that they forgot ntohs() calls. +uint16 ntows(uint16 neshort) +{ + return ((neshort & 0xFF) << 8) | ((neshort & 0xFF00) >> 8); +} diff --git a/src/common/socket.h b/src/common/socket.h index 41acbeabd..801da8807 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -130,6 +130,7 @@ uint32 host2ip(const char* hostname); const char* ip2str(uint32 ip, char ip_str[16]); uint32 str2ip(const char* ip_str); #define CONVIP(ip) (ip>>24)&0xFF,(ip>>16)&0xFF,(ip>>8)&0xFF,(ip>>0)&0xFF +uint16 ntows(uint16 netshort); int socket_getips(uint32* ips, int max); |