summaryrefslogtreecommitdiff
path: root/src/map/chrif.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-22 01:12:52 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-06-22 01:12:52 +0000
commit8ecd9729cb7da906470a88decb77620ed3d7ffdf (patch)
tree23486d0498a03b341b7f2a6bca2543a7705fe63d /src/map/chrif.c
parent0c74559d80136821bee587473b01dab5935ebf26 (diff)
downloadhercules-8ecd9729cb7da906470a88decb77620ed3d7ffdf.tar.gz
hercules-8ecd9729cb7da906470a88decb77620ed3d7ffdf.tar.bz2
hercules-8ecd9729cb7da906470a88decb77620ed3d7ffdf.tar.xz
hercules-8ecd9729cb7da906470a88decb77620ed3d7ffdf.zip
- 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
Diffstat (limited to 'src/map/chrif.c')
-rw-r--r--src/map/chrif.c24
1 files changed, 11 insertions, 13 deletions
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 <stdio.h>
#include <stdlib.h>
#include <string.h>
-#ifdef _WIN32
-#include <winsock.h>
-#else
-#include <unistd.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#endif
#include <sys/types.h>
#include <time.h>
#include <limits.h>
@@ -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];