diff options
-rw-r--r-- | src/char/char.c | 10 | ||||
-rw-r--r-- | src/common/core.c | 21 | ||||
-rw-r--r-- | src/common/core.h | 1 | ||||
-rw-r--r-- | src/common/mmo.h | 2 | ||||
-rw-r--r-- | src/common/socket.c | 7 | ||||
-rw-r--r-- | src/common/socket.h | 1 | ||||
-rw-r--r-- | src/common/utils.h | 4 | ||||
-rw-r--r-- | src/login/login.c | 21 | ||||
-rw-r--r-- | src/login_sql/login.c | 6 | ||||
-rw-r--r-- | src/map/atcommand.c | 1 | ||||
-rw-r--r-- | src/map/battle.c | 7 | ||||
-rw-r--r-- | src/map/map.c | 1 | ||||
-rw-r--r-- | src/map/vending.c | 6 | ||||
-rw-r--r-- | src/tool/mapcache.c | 8 |
14 files changed, 46 insertions, 50 deletions
diff --git a/src/char/char.c b/src/char/char.c index 4cef440bc..705579fbf 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -3977,9 +3977,9 @@ int char_lan_config_read(const char *lancfgName) { if(strcmpi(w1, "subnet") == 0) { - subnet[subnet_count].mask = ntohl(inet_addr(w2)); - subnet[subnet_count].char_ip = ntohl(inet_addr(w3)); - subnet[subnet_count].map_ip = ntohl(inet_addr(w4)); + subnet[subnet_count].mask = str2ip(w2); + subnet[subnet_count].char_ip = str2ip(w3); + subnet[subnet_count].map_ip = str2ip(w4); subnet[subnet_count].subnet = subnet[subnet_count].char_ip&subnet[subnet_count].mask; if (subnet[subnet_count].subnet != (subnet[subnet_count].map_ip&subnet[subnet_count].mask)) { ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4); @@ -4284,11 +4284,11 @@ int do_init(int argc, char **argv) ShowStatus("Defaulting to %s as our IP address\n", ip_str); if (!login_ip) { strcpy(login_ip_str, ip_str); - login_ip = ntohl(inet_addr(login_ip_str)); + login_ip = str2ip(login_ip_str); } if (!char_ip) { strcpy(char_ip_str, ip_str); - char_ip = ntohl(inet_addr(char_ip_str)); + char_ip = str2ip(char_ip_str); } } diff --git a/src/common/core.c b/src/common/core.c index d38f1597a..33b855d87 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -32,18 +32,9 @@ char **arg_v = NULL; char *SERVER_NAME = NULL; char SERVER_TYPE = ATHENA_SERVER_NONE; -static void (*term_func)(void) = NULL; #ifndef SVNVERSION static char eA_svn_version[10]; #endif -/*====================================== - * CORE : Set function - *-------------------------------------- - */ -void set_termfunc(void (*termfunc)(void)) -{ - term_func = termfunc; -} #ifndef MINICORE // minimalist Core // Added by Gabuzomeu @@ -120,9 +111,8 @@ void signals_init (void) compat_signal(SIGSEGV, sig_proc); compat_signal(SIGFPE, sig_proc); #endif - // Signal to create coredumps by system when necessary (crash) - compat_signal(SIGILL, SIG_DFL); #ifndef _WIN32 + compat_signal(SIGILL, SIG_DFL); compat_signal(SIGXFSZ, sig_proc); compat_signal(SIGPIPE, sig_proc); compat_signal(SIGBUS, SIG_DFL); @@ -189,10 +179,8 @@ const char* get_svn_revision(void) */ static void display_title(void) { - //The clearscreeen is usually more of an annoyance than anything else... [Skotlex] -// ClearScreen(); // clear screen and go up/left (0, 0 position in text) - //ShowMessage("\n"); //A blank message?? - printf("\n"); + //ClearScreen(); // clear screen and go up/left (0, 0 position in text) + ShowMessage("\n"); ShowMessage(""CL_WTBL" (=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=)"CL_CLL""CL_NORMAL"\n"); // white writing (37) on blue background (44), \033[K clean until end of file ShowMessage(""CL_XXBL" ("CL_BT_YELLOW" (c)2005 eAthena Development Team presents "CL_XXBL")"CL_CLL""CL_NORMAL"\n"); // yellow writing (33) ShowMessage(""CL_XXBL" ("CL_BOLD" ______ __ __ "CL_XXBL")"CL_CLL""CL_NORMAL"\n"); // 1: bold char, 0: normal char @@ -213,7 +201,8 @@ static void display_title(void) } // Warning if logged in as superuser (root) -void usercheck(void){ +void usercheck(void) +{ #ifndef _WIN32 if ((getuid() == 0) && (getgid() == 0)) { ShowWarning ("You are running eAthena as the root superuser.\n"); diff --git a/src/common/core.h b/src/common/core.h index f59a87e3e..7784a95bb 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -17,7 +17,6 @@ extern int parse_console(char* buf); extern const char *get_svn_revision(void); extern int do_init(int,char**); extern void set_server_type(void); -extern void set_termfunc(void (*termfunc)(void)); extern void do_abort(void); extern void do_final(void); diff --git a/src/common/mmo.h b/src/common/mmo.h index 8d5071cc2..75b741697 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -503,8 +503,6 @@ enum { #define strnicmp strncasecmp #endif #else - #define snprintf _snprintf - #define vsnprintf _vsnprintf #ifndef strncmpi #define strncmpi strnicmp #endif diff --git a/src/common/socket.c b/src/common/socket.c index b2c9810b4..6d89b26e6 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -57,6 +57,7 @@ #include "../common/timer.h" #include "../common/malloc.h" #include "../common/showmsg.h" +#include "../common/strlib.h" fd_set readfds; int fd_max; @@ -1110,3 +1111,9 @@ const char* ip2str(uint32 ip, char ip_str[16]) addr.s_addr = htonl(ip); return (ip_str == NULL) ? inet_ntoa(addr) : strncpy(ip_str, inet_ntoa(addr), 16); } + +// Converts a dot-formatted ip string into a numeric ip. +uint32 str2ip(const char* ip_str) +{ + return ntohl(inet_addr(ip_str)); +} diff --git a/src/common/socket.h b/src/common/socket.h index ba984eb3a..eae9baf72 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -128,6 +128,7 @@ void set_defaultparse(ParseFunc defaultparse); // hostname/ip conversion functions 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 int socket_getips(uint32* ips, int max); diff --git a/src/common/utils.h b/src/common/utils.h index 496cbdde3..3fd0aeacc 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -6,10 +6,6 @@ #include <stdarg.h> -#ifndef NULL -#define NULL (void *)0 -#endif - void dump(unsigned char *buffer, int num); struct StringBuf { diff --git a/src/login/login.c b/src/login/login.c index c11bb2e74..c7ff64446 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -387,18 +387,21 @@ int read_gm_account(void) { int check_ipmask(uint32 ip, const unsigned char *str) { unsigned int i = 0, m = 0; - unsigned int ip2, mask = 0; - unsigned char *p = (unsigned char *)&ip2, *p2 = (unsigned char *)&mask; + uint32 ip2, mask = 0; + uint32 a0, a1, a2, a3; + uint8* p = (uint8 *)&ip2, *p2 = (uint8 *)&mask; + // scan ip address - if (sscanf((const char*)str, "%u.%u.%u.%u/%n", &p[3], &p[2], &p[1], &p[0], &i) != 4 || i == 0) + if (sscanf((const char*)str, "%u.%u.%u.%u/%n", &a0, &a1, &a2, &a3, &i) != 4 || i == 0) return 0; + p[0] = (uint8)a3; p[1] = (uint8)a2; p[2] = (uint8)a1; p[3] = (uint8)a0; // scan mask - if (sscanf((const char*)str+i, "%u.%u.%u.%u", &p2[3], &p2[2], &p2[1], &p2[0]) == 4) { - ; + if (sscanf((const char*)str+i, "%u.%u.%u.%u", &a0, &a1, &a2, &a3) == 4) { + p2[0] = (uint8)a3; p2[1] = (uint8)a2; p2[2] = (uint8)a1; p2[3] = (uint8)a0; } else if (sscanf((const char*)(str+i), "%u", &m) == 1 && m >= 0 && m <= 32) { - for(i = 0; i < m && i < 32; i++) + for(i = 32 - m; i < 32; i++) mask |= (1 << i); } else { ShowError("check_ipmask: invalid mask [%s].\n", str); @@ -3445,9 +3448,9 @@ int login_lan_config_read(const char *lancfgName) if(strcmpi(w1, "subnet") == 0) { - subnet[subnet_count].mask = ntohl(inet_addr(w2)); - subnet[subnet_count].char_ip = ntohl(inet_addr(w3)); - subnet[subnet_count].map_ip = ntohl(inet_addr(w4)); + subnet[subnet_count].mask = str2ip(w2); + subnet[subnet_count].char_ip = str2ip(w3); + subnet[subnet_count].map_ip = str2ip(w4); subnet[subnet_count].subnet = subnet[subnet_count].char_ip&subnet[subnet_count].mask; if (subnet[subnet_count].subnet != (subnet[subnet_count].map_ip&subnet[subnet_count].mask)) { ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4); diff --git a/src/login_sql/login.c b/src/login_sql/login.c index eff42ffb8..90a1b0981 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -1765,9 +1765,9 @@ int login_lan_config_read(const char *lancfgName) if(strcmpi(w1, "subnet") == 0) { - subnet[subnet_count].mask = ntohl(inet_addr(w2)); - subnet[subnet_count].char_ip = ntohl(inet_addr(w3)); - subnet[subnet_count].map_ip = ntohl(inet_addr(w4)); + subnet[subnet_count].mask = str2ip(w2); + subnet[subnet_count].char_ip = str2ip(w3); + subnet[subnet_count].map_ip = str2ip(w4); subnet[subnet_count].subnet = subnet[subnet_count].char_ip&subnet[subnet_count].mask; if (subnet[subnet_count].subnet != (subnet[subnet_count].map_ip&subnet[subnet_count].mask)) { ShowError("%s: Configuration Error: The char server (%s) and map server (%s) belong to different subnetworks!\n", lancfgName, w3, w4); diff --git a/src/map/atcommand.c b/src/map/atcommand.c index f947c0b3b..6acd8334f 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -15,6 +15,7 @@ #include "../common/showmsg.h" #include "../common/malloc.h" #include "../common/socket.h" +#include "../common/strlib.h" #include "atcommand.h" #include "log.h" diff --git a/src/map/battle.c b/src/map/battle.c index 6eda8fa78..54c416ae7 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -12,6 +12,7 @@ #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/ers.h" +#include "../common/strlib.h" #include "map.h" #include "pc.h" @@ -3710,7 +3711,7 @@ int battle_set_value(const char* w1, const char* w2) { int i; for(i = 0; i < sizeof(battle_data_short) / (sizeof(battle_data_short[0])); i++) if (strcmpi(w1, battle_data_short[i].str) == 0) { - * battle_data_short[i].val = config_switch(w2); + *battle_data_short[i].val = config_switch(w2); return 1; } for(i = 0; i < sizeof(battle_data_int) / (sizeof(battle_data_int[0])); i++) @@ -3725,7 +3726,7 @@ int battle_get_value(const char* w1) { int i; for(i = 0; i < sizeof(battle_data_short) / (sizeof(battle_data_short[0])); i++) if (strcmpi(w1, battle_data_short[i].str) == 0) { - return * battle_data_short[i].val; + return *battle_data_short[i].val; } for(i = 0; i < sizeof(battle_data_int) / (sizeof(battle_data_int[0])); i++) if (strcmpi(w1, battle_data_int[i].str) == 0) { @@ -4236,7 +4237,7 @@ void battle_validate_conf() { if (battle_config.any_warp_GM_min_level > 100) battle_config.any_warp_GM_min_level = 100; - if (battle_config.vending_max_value > MAX_ZENY || battle_config.vending_max_value==0) + if (battle_config.vending_max_value > MAX_ZENY || battle_config.vending_max_value <= 0) battle_config.vending_max_value = MAX_ZENY; if (battle_config.vending_tax > 10000) diff --git a/src/map/map.c b/src/map/map.c index 43140677e..d02c6da55 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -20,6 +20,7 @@ #include "../common/showmsg.h" #include "../common/version.h" #include "../common/nullpo.h" +#include "../common/strlib.h" #include "map.h" #include "chrif.h" diff --git a/src/map/vending.c b/src/map/vending.c index 63551272c..44f1a0f11 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -227,7 +227,7 @@ void vending_openvending(struct map_session_data *sd,int len,char *message,int f vending_skill_lvl = pc_checkskill(sd, MC_VENDING); if(!vending_skill_lvl || !pc_iscarton(sd)) { // cart skill and cart check [Valaris] - clif_skill_fail(sd,MC_VENDING,0,0); + clif_skill_fail(sd, MC_VENDING, 0, 0); return; } @@ -247,8 +247,8 @@ void vending_openvending(struct map_session_data *sd,int len,char *message,int f } sd->vending[i].amount = *(short*)(p+2+8*j); sd->vending[i].value = *(int*)(p+4+8*j); - if(sd->vending[i].value > battle_config.vending_max_value) - sd->vending[i].value=battle_config.vending_max_value; + if(sd->vending[i].value > (unsigned int)battle_config.vending_max_value) + sd->vending[i].value = (unsigned int)battle_config.vending_max_value; else if(sd->vending[i].value < 1) sd->vending[i].value = 1000000; // auto set to 1 million [celest] // カート内のアイテム数と販売するアイテム数に相違があったら中止 diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index 32680f917..a1b537a56 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -163,7 +163,7 @@ int read_map(char *name, struct map_data *m) void cache_map(char *name, struct map_data *m) { struct map_info info; - long len; + unsigned long len; unsigned char *write_buf; // Create an output buffer twice as big as the uncompressed map... this way we're sure it fits @@ -218,9 +218,9 @@ char *remove_extension(char *mapname) if (ptr) { //Check and remove extension. while (ptr[1] && (ptr2 = strchr(ptr+1, '.'))) ptr = ptr2; //Skip to the last dot. - if(stricmp(ptr,".gat") == 0 || - stricmp(ptr,".afm") == 0 || - stricmp(ptr,".af2") == 0) + if(strcmp(ptr,".gat") == 0 || + strcmp(ptr,".afm") == 0 || + strcmp(ptr,".af2") == 0) *ptr = '\0'; //Remove extension. } return mapname; |