From 8ecd9729cb7da906470a88decb77620ed3d7ffdf Mon Sep 17 00:00:00 2001 From: skotlex Date: Thu, 22 Jun 2006 01:12:52 +0000 Subject: - Tested and fixed resolve_hostbyname. - Applied said function around most of the code where needed. Removed includes for the OS/network system pretty much from every file (our socket.c file should handle this) - Added clif_getip_long, which returns the ip as a long. Prevents having to include the files to define the int_addr structure in all files that include clif.h - Made the GM mute request bypass the manner_system setting. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7285 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/chrif.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/map/chrif.c') diff --git a/src/map/chrif.c b/src/map/chrif.c index 2396f5175..19002eab4 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -4,14 +4,6 @@ #include #include #include -#ifdef _WIN32 -#include -#else -#include -#include -#include -#include -#endif #include #include #include @@ -151,10 +143,16 @@ void chrif_checkdefaultlogin(void) * *------------------------------------------ */ -void chrif_setip(char *ip) +int chrif_setip(char *ip) { - memcpy(&char_ip_str, ip, 16); - char_ip = inet_addr(char_ip_str); + char_ip = resolve_hostbyname(ip,NULL,char_ip_str); + + if (!char_ip) { + ShowWarning("Failed to Resolve Char Server Address! (%s)\n", ip); + return 0; + } + ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, char_ip_str); + return 1; } /*========================================== @@ -239,7 +237,7 @@ int chrif_connect(int fd) memcpy(WFIFOP(fd,2), userid, NAME_LENGTH); memcpy(WFIFOP(fd,26), passwd, NAME_LENGTH); WFIFOL(fd,50) = 0; - WFIFOL(fd,54) = clif_getip(); + WFIFOL(fd,54) = clif_getip_long(); WFIFOW(fd,58) = clif_getport(); // [Valaris] thanks to fov WFIFOSET(fd,60); @@ -1417,7 +1415,7 @@ int chrif_disconnect(int fd) { void chrif_update_ip(int fd){ char ip[4]; ShowInfo("IP Sync in progress...\n"); - if (map_server_dns && resolve_hostbyname(map_server_dns, ip)) { + if (map_server_dns && resolve_hostbyname(map_server_dns, ip, NULL)) { WFIFOW(fd, 0) = 0x2736; WFIFOB(fd, 2) = ip[0]; WFIFOB(fd, 3) = ip[1]; -- cgit v1.2.3-70-g09d2