* Some source code cleaning
- Fixed the badly worded messages during mapserver startup - Cleaned up socket config reading - Split resolve_hostbyname() into 2 separate functions for clarity - Moved the probably obsolete LOWER/UPPER macros to db.c (TODO: remove) - Moved the badly placed compare_item() function to storage.c (see r779) git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@10119 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
99fb323a0a
commit
a167b6ae62
@ -4,6 +4,12 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
|
||||
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||
|
||||
2007/04/03
|
||||
* Some source code cleaning
|
||||
- Fixed the badly worded messages during mapserver startup
|
||||
- Cleaned up socket config reading
|
||||
- Split resolve_hostbyname() into 2 separate functions for clarity
|
||||
- Moved the probably obsolete LOWER/UPPER macros to db.c (TODO: remove)
|
||||
- Moved the badly placed compare_item() function to storage.c (see r779)
|
||||
* Fully removed the msvcr80.dll dependency from the vs8 project files
|
||||
2007/04/02
|
||||
* Removed some overly verbose item group messages & code
|
||||
|
@ -2478,11 +2478,11 @@ int parse_tologin(int fd) {
|
||||
WBUFW(buf,0) = 0x2b1e;
|
||||
mapif_sendall(buf, 2);
|
||||
|
||||
new_ip = resolve_hostbyname(login_ip_str, NULL, NULL);
|
||||
new_ip = host2ip(login_ip_str);
|
||||
if (new_ip && new_ip != login_ip)
|
||||
login_ip = new_ip; //Update login up.
|
||||
|
||||
new_ip = resolve_hostbyname(char_ip_str, NULL, NULL);
|
||||
new_ip = host2ip(char_ip_str);
|
||||
if (new_ip && new_ip != char_ip)
|
||||
{ //Update ip.
|
||||
WFIFOHEAD(fd,6);
|
||||
@ -4113,26 +4113,26 @@ int char_config_read(const char *cfgName) {
|
||||
}
|
||||
} else if (strcmpi(w1, "login_ip") == 0) {
|
||||
char ip_str[16];
|
||||
login_ip = resolve_hostbyname(w2, NULL, ip_str);
|
||||
login_ip = host2ip(w2);
|
||||
if (login_ip) {
|
||||
strncpy(login_ip_str, w2, sizeof(login_ip_str));
|
||||
ShowStatus("Login server IP address : %s -> %s\n", w2, ip_str);
|
||||
ShowStatus("Login server IP address : %s -> %s\n", w2, ip2str(login_ip, ip_str));
|
||||
}
|
||||
} else if (strcmpi(w1, "login_port") == 0) {
|
||||
login_port = atoi(w2);
|
||||
} else if (strcmpi(w1, "char_ip") == 0) {
|
||||
char ip_str[16];
|
||||
char_ip = resolve_hostbyname(w2, NULL, ip_str);
|
||||
char_ip = host2ip(w2);
|
||||
if (char_ip){
|
||||
strncpy(char_ip_str, w2, sizeof(char_ip_str));
|
||||
ShowStatus("Character server IP address : %s -> %s\n", w2, ip_str);
|
||||
ShowStatus("Character server IP address : %s -> %s\n", w2, ip2str(char_ip, ip_str));
|
||||
}
|
||||
} else if (strcmpi(w1, "bind_ip") == 0) {
|
||||
char ip_str[16];
|
||||
bind_ip = resolve_hostbyname(w2, NULL, ip_str);
|
||||
bind_ip = host2ip(w2);
|
||||
if (bind_ip) {
|
||||
strncpy(bind_ip_str, w2, sizeof(bind_ip_str));
|
||||
ShowStatus("Character server binding IP address : %s -> %s\n", w2, ip_str);
|
||||
ShowStatus("Character server binding IP address : %s -> %s\n", w2, ip2str(bind_ip, ip_str));
|
||||
}
|
||||
} else if (strcmpi(w1, "char_port") == 0) {
|
||||
char_port = atoi(w2);
|
||||
|
@ -2245,11 +2245,11 @@ int parse_tologin(int fd) {
|
||||
WBUFW(buf,0) = 0x2b1e;
|
||||
mapif_sendall(buf, 2);
|
||||
|
||||
new_ip = resolve_hostbyname(login_ip_str, NULL, NULL);
|
||||
new_ip = host2ip(login_ip_str);
|
||||
if (new_ip && new_ip != login_ip) //Update login ip, too.
|
||||
login_ip = new_ip;
|
||||
|
||||
new_ip = resolve_hostbyname(char_ip_str, NULL, NULL);
|
||||
new_ip = host2ip(char_ip_str);
|
||||
if (new_ip && new_ip != char_ip)
|
||||
{ //Update ip.
|
||||
char_ip = new_ip;
|
||||
@ -4059,27 +4059,27 @@ int char_config_read(const char *cfgName) {
|
||||
wisp_server_name[sizeof(wisp_server_name) - 1] = '\0';
|
||||
}
|
||||
} else if (strcmpi(w1, "login_ip") == 0) {
|
||||
unsigned char ip_str[16];
|
||||
login_ip = resolve_hostbyname(w2, NULL, ip_str);
|
||||
char ip_str[16];
|
||||
login_ip = host2ip(w2);
|
||||
if (login_ip) {
|
||||
strncpy(login_ip_str, w2, sizeof(login_ip_str));
|
||||
ShowStatus("Login server IP address : %s -> %s\n", w2, ip_str);
|
||||
ShowStatus("Login server IP address : %s -> %s\n", w2, ip2str(login_ip, ip_str));
|
||||
}
|
||||
} else if (strcmpi(w1, "login_port") == 0) {
|
||||
login_port=atoi(w2);
|
||||
} else if (strcmpi(w1, "char_ip") == 0) {
|
||||
unsigned char ip_str[16];
|
||||
char_ip = resolve_hostbyname(w2, NULL, ip_str);
|
||||
char ip_str[16];
|
||||
char_ip = host2ip(w2);
|
||||
if (char_ip){
|
||||
strncpy(char_ip_str, w2, sizeof(char_ip_str));
|
||||
ShowStatus("Character server IP address : %s -> %s\n", w2, ip_str);
|
||||
ShowStatus("Character server IP address : %s -> %s\n", w2, ip2str(char_ip, ip_str));
|
||||
}
|
||||
} else if (strcmpi(w1, "bind_ip") == 0) {
|
||||
unsigned char ip_str[16];
|
||||
bind_ip = resolve_hostbyname(w2, NULL, ip_str);
|
||||
char ip_str[16];
|
||||
bind_ip = host2ip(w2);
|
||||
if (bind_ip) {
|
||||
strncpy(bind_ip_str, w2, sizeof(bind_ip_str));
|
||||
ShowStatus("Character server binding IP address : %s -> %s\n", w2, ip_str);
|
||||
ShowStatus("Character server binding IP address : %s -> %s\n", w2, ip2str(bind_ip, ip_str));
|
||||
}
|
||||
} else if (strcmpi(w1, "char_port") == 0) {
|
||||
char_port = atoi(w2);
|
||||
|
@ -75,6 +75,10 @@
|
||||
#include "../common/showmsg.h"
|
||||
#include "../common/ers.h"
|
||||
|
||||
//TODO: get rid of this
|
||||
#define LOWER(c) (((c)>='A' && (c) <= 'Z') ? ((c)+('a'-'A')) : (c))
|
||||
#define UPPER(c) (((c)>='a' && (c) <= 'z') ? ((c)+('A'-'a')) : (c))
|
||||
|
||||
/*****************************************************************************\
|
||||
* (1) Private typedefs, enums, structures, defines and global variables of *
|
||||
* the database system. *
|
||||
|
@ -846,8 +846,7 @@ int access_ipmask(const char* str, AccessControl* acc)
|
||||
}
|
||||
}
|
||||
if( access_debug ){
|
||||
ShowMessage("access_ipmask: Loaded IP:%d.%d.%d.%d mask:%d.%d.%d.%d\n",
|
||||
CONVIP(ip), CONVIP(mask));
|
||||
ShowMessage("access_ipmask: Loaded IP:%d.%d.%d.%d mask:%d.%d.%d.%d\n", CONVIP(ip), CONVIP(mask));
|
||||
}
|
||||
acc->ip = ip;
|
||||
acc->mask = mask;
|
||||
@ -857,8 +856,8 @@ int access_ipmask(const char* str, AccessControl* acc)
|
||||
#endif
|
||||
//////////////////////////////
|
||||
|
||||
int socket_config_read(const char *cfgName) {
|
||||
int i;
|
||||
int socket_config_read(const char *cfgName)
|
||||
{
|
||||
char line[1024],w1[1024],w2[1024];
|
||||
FILE *fp;
|
||||
|
||||
@ -867,59 +866,52 @@ int socket_config_read(const char *cfgName) {
|
||||
ShowError("File not found: %s\n", cfgName);
|
||||
return 1;
|
||||
}
|
||||
while(fgets(line,1020,fp)){
|
||||
|
||||
while(fgets(line,1020,fp))
|
||||
{
|
||||
if(line[0] == '/' && line[1] == '/')
|
||||
continue;
|
||||
i=sscanf(line,"%[^:]: %[^\r\n]",w1,w2);
|
||||
if(i!=2)
|
||||
if(sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
|
||||
continue;
|
||||
if(strcmpi(w1,"stall_time")==0){
|
||||
|
||||
if (!strcmpi(w1, "stall_time"))
|
||||
stall_time = atoi(w2);
|
||||
#ifndef MINICORE
|
||||
} else if( strcmpi(w1,"enable_ip_rules") == 0 ){
|
||||
if( strcmpi(w2,"yes") == 0 )
|
||||
ip_rules = 1;
|
||||
else if( strcmpi(w2,"no") == 0 )
|
||||
ip_rules = 0;
|
||||
else
|
||||
ip_rules = atoi(w2);
|
||||
} else if( strcmpi(w1,"order") == 0 ){
|
||||
access_order = atoi(w2);
|
||||
if( strcmpi(w2,"deny,allow") == 0 )
|
||||
else if (!strcmpi(w1, "enable_ip_rules")) {
|
||||
ip_rules = config_switch(w2);
|
||||
} else if (!strcmpi(w1, "order")) {
|
||||
if (!strcmpi(w2, "deny,allow"))
|
||||
access_order = ACO_DENY_ALLOW;
|
||||
else if( strcmpi(w2,"allow,deny") == 0 )
|
||||
else if (!strcmpi(w2, "allow,deny"))
|
||||
access_order = ACO_ALLOW_DENY;
|
||||
else if( strcmpi(w2,"mutual-failure") == 0 )
|
||||
else if (!strcmpi(w2, "mutual-failure"))
|
||||
access_order = ACO_MUTUAL_FAILURE;
|
||||
} else if( strcmpi(w1,"allow") == 0 ){
|
||||
} else if (!strcmpi(w1, "allow")) {
|
||||
RECREATE(access_allow, AccessControl, access_allownum+1);
|
||||
if (access_ipmask(w2, &access_allow[access_allownum]))
|
||||
++access_allownum;
|
||||
else
|
||||
ShowError("socket_config_read: Invalid ip or ip range '%s'!\n", line);
|
||||
} else if( strcmpi(w1,"deny") == 0 ){
|
||||
} else if (!strcmpi(w1, "deny")) {
|
||||
RECREATE(access_deny, AccessControl, access_denynum+1);
|
||||
if (access_ipmask(w2, &access_deny[access_denynum]))
|
||||
++access_denynum;
|
||||
else
|
||||
ShowError("socket_config_read: Invalid ip or ip range '%s'!\n", line);
|
||||
} else if( strcmpi(w1,"ddos_interval") == 0){
|
||||
}
|
||||
else if (!strcmpi(w1,"ddos_interval"))
|
||||
ddos_interval = atoi(w2);
|
||||
} else if( strcmpi(w1,"ddos_count") == 0){
|
||||
else if (!strcmpi(w1,"ddos_count"))
|
||||
ddos_count = atoi(w2);
|
||||
} else if( strcmpi(w1,"ddos_autoreset") == 0){
|
||||
else if (!strcmpi(w1,"ddos_autoreset"))
|
||||
ddos_autoreset = atoi(w2);
|
||||
} else if( strcmpi(w1,"debug") == 0){
|
||||
if( strcmpi(w2,"yes") == 0 )
|
||||
access_debug = 1;
|
||||
else if( strcmpi(w2,"no") == 0 )
|
||||
access_debug = 0;
|
||||
else
|
||||
access_debug = atoi(w2);
|
||||
else if (!strcmpi(w1,"debug"))
|
||||
access_debug = config_switch(w2);
|
||||
#endif
|
||||
} else if (strcmpi(w1, "import") == 0)
|
||||
else if (!strcmpi(w1, "import"))
|
||||
socket_config_read(w2);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
@ -1107,18 +1099,16 @@ int session_isActive(int fd)
|
||||
return ( session_isValid(fd) && !session[fd]->eof );
|
||||
}
|
||||
|
||||
in_addr_t resolve_hostbyname(const char* hostname, unsigned char* ip, char* ip_str)
|
||||
|
||||
in_addr_t host2ip(const char* hostname)
|
||||
{
|
||||
struct hostent* h = gethostbyname(hostname);
|
||||
char ip_buf[16];
|
||||
unsigned char ip2[4];
|
||||
if (!h) return 0;
|
||||
if (ip == NULL) ip = ip2;
|
||||
ip[0] = (unsigned char) h->h_addr[0];
|
||||
ip[1] = (unsigned char) h->h_addr[1];
|
||||
ip[2] = (unsigned char) h->h_addr[2];
|
||||
ip[3] = (unsigned char) h->h_addr[3];
|
||||
if (ip_str == NULL) ip_str = ip_buf;
|
||||
sprintf(ip_str, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
|
||||
return inet_addr(ip_str);
|
||||
return (h != NULL) ? *(in_addr_t*)h->h_addr : 0;
|
||||
}
|
||||
|
||||
const char* ip2str(in_addr_t ip, char ip_str[16])
|
||||
{
|
||||
in_addr_t addr = ntohl(ip);
|
||||
sprintf(ip_str, "%d.%d.%d.%d", (addr>>24)&0xFF, (addr>>16)&0xFF, (addr>>8)&0xFF, (addr>>0)&0xFF);
|
||||
return ip_str;
|
||||
}
|
||||
|
@ -125,13 +125,10 @@ extern void set_nonblocking(int fd, int yes);
|
||||
|
||||
void set_defaultparse(ParseFunc defaultparse);
|
||||
|
||||
//Resolves the hostname and stores the string representation of the string in ip.
|
||||
//Meant to simplify calls to gethostbyname without the need of all the
|
||||
//required network includes.
|
||||
//hostname is the name to resolve.
|
||||
//ip is an array of char[4] where the individual parts of the ip are stored (optional)
|
||||
//ip_str is a char[16] where the whole ip is stored in string notation (optional)
|
||||
in_addr_t resolve_hostbyname(const char* hostname, unsigned char* ip, char* ip_str);
|
||||
// hostname/ip conversion functions
|
||||
in_addr_t host2ip(const char* hostname);
|
||||
const char* ip2str(in_addr_t ip, char ip_str[16]);
|
||||
|
||||
|
||||
int socket_getips(uint32* ips, int max);
|
||||
|
||||
|
@ -10,9 +10,6 @@
|
||||
#define NULL (void *)0
|
||||
#endif
|
||||
|
||||
#define LOWER(c) (((c)>='A' && (c) <= 'Z') ? ((c)+('a'-'A')) : (c))
|
||||
#define UPPER(c) (((c)>='a' && (c) <= 'z') ? ((c)+('A'-'a')) : (c) )
|
||||
|
||||
void dump(unsigned char *buffer, int num);
|
||||
|
||||
struct StringBuf {
|
||||
|
@ -3636,10 +3636,10 @@ int login_config_read(const char* cfgName)
|
||||
} else if (strcmpi(w1, "new_account") == 0) {
|
||||
new_account_flag = config_switch(w2);
|
||||
} else if (strcmpi(w1, "bind_ip") == 0) {
|
||||
char login_ip_str[128];
|
||||
login_ip = resolve_hostbyname(w2, NULL, login_ip_str);
|
||||
char ip_str[16];
|
||||
login_ip = host2ip(w2);
|
||||
if (login_ip)
|
||||
ShowStatus("Login server binding IP address : %s -> %s\n", w2, login_ip_str);
|
||||
ShowStatus("Login server binding IP address : %s -> %s\n", w2, ip2str(login_ip, ip_str));
|
||||
} else if (strcmpi(w1, "login_port") == 0) {
|
||||
login_port = atoi(w2);
|
||||
} else if (strcmpi(w1, "account_filename") == 0) {
|
||||
|
@ -1899,10 +1899,10 @@ int login_config_read(const char* cfgName)
|
||||
msg_silent = atoi(w2);
|
||||
}
|
||||
else if (!strcmpi(w1, "bind_ip")) {
|
||||
char login_ip_str[128];
|
||||
login_config.login_ip = resolve_hostbyname(w2, NULL, login_ip_str);
|
||||
char ip_str[16];
|
||||
login_config.login_ip = host2ip(w2);
|
||||
if (login_config.login_ip)
|
||||
ShowStatus("Login server binding IP address : %s -> %s\n", w2, login_ip_str);
|
||||
ShowStatus("Login server binding IP address : %s -> %s\n", w2, ip2str(login_config.login_ip, ip_str));
|
||||
} else if(!strcmpi(w1,"login_port")) {
|
||||
login_config.login_port = (unsigned short)atoi(w2);
|
||||
ShowStatus("set login_port : %s\n",w2);
|
||||
|
@ -143,17 +143,16 @@ void chrif_checkdefaultlogin(void)
|
||||
*
|
||||
*------------------------------------------
|
||||
*/
|
||||
int chrif_setip(char *ip)
|
||||
int chrif_setip(const char *ip)
|
||||
{
|
||||
char ip_str[16];
|
||||
char_ip = resolve_hostbyname(ip,NULL,ip_str);
|
||||
|
||||
char_ip = host2ip(ip);
|
||||
if (!char_ip) {
|
||||
ShowWarning("Failed to Resolve Char Server Address! (%s)\n", ip);
|
||||
return 0;
|
||||
}
|
||||
strncpy(char_ip_str, ip, sizeof(char_ip_str));
|
||||
ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip_str);
|
||||
ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(char_ip, ip_str));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1418,10 +1417,11 @@ int chrif_disconnect(int fd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void chrif_update_ip(int fd){
|
||||
void chrif_update_ip(int fd)
|
||||
{
|
||||
unsigned long new_ip;
|
||||
WFIFOHEAD(fd, 6);
|
||||
new_ip = resolve_hostbyname(char_ip_str, NULL, NULL);
|
||||
new_ip = host2ip(char_ip_str);
|
||||
if (new_ip && new_ip != char_ip)
|
||||
char_ip = new_ip; //Update char_ip
|
||||
|
||||
|
@ -15,7 +15,7 @@ struct auth_node{
|
||||
void chrif_setuserid(char*);
|
||||
void chrif_setpasswd(char*);
|
||||
void chrif_checkdefaultlogin(void);
|
||||
int chrif_setip(char*);
|
||||
int chrif_setip(const char*);
|
||||
void chrif_setport(int);
|
||||
|
||||
int chrif_isconnect(void);
|
||||
|
@ -116,23 +116,23 @@ static void clif_hpmeter_single(int fd, struct map_session_data *sd);
|
||||
int clif_setip(const char* ip)
|
||||
{
|
||||
char ip_str[16];
|
||||
map_ip = resolve_hostbyname(ip,NULL,ip_str);
|
||||
map_ip = host2ip(ip);
|
||||
if (!map_ip) {
|
||||
ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip);
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncpy(map_ip_str, ip, sizeof(map_ip_str));
|
||||
ShowInfo("Map Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip_str);
|
||||
ShowInfo("Map Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(map_ip, ip_str));
|
||||
return 1;
|
||||
}
|
||||
|
||||
void clif_setbindip(const char* ip)
|
||||
{
|
||||
unsigned char ip_str[4];
|
||||
bind_ip = resolve_hostbyname(ip,ip_str,NULL);
|
||||
char ip_str[16];
|
||||
bind_ip = host2ip(ip);
|
||||
if (bind_ip) {
|
||||
ShowInfo("Map Server Bind IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%d.%d.%d.%d"CL_RESET"'.\n", ip, ip_str[0], ip_str[1], ip_str[2], ip_str[3]);
|
||||
ShowInfo("Map Server Bind IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(bind_ip, ip_str));
|
||||
} else {
|
||||
ShowWarning("Failed to Resolve Map Server Address! (%s)\n", ip);
|
||||
}
|
||||
@ -162,12 +162,12 @@ unsigned long clif_getip_long(void)
|
||||
return (unsigned long)map_ip;
|
||||
}
|
||||
|
||||
//Refreshes map_server ip, returns the new ip if the ip changed, otherwise it
|
||||
//returns 0.
|
||||
unsigned long clif_refresh_ip(void) {
|
||||
//Refreshes map_server ip, returns the new ip if the ip changed, otherwise it returns 0.
|
||||
unsigned long clif_refresh_ip(void)
|
||||
{
|
||||
in_addr_t new_ip;
|
||||
|
||||
new_ip = resolve_hostbyname(map_ip_str, NULL, NULL);
|
||||
new_ip = host2ip(map_ip_str);
|
||||
if (new_ip && new_ip != map_ip) {
|
||||
map_ip = new_ip;
|
||||
ShowInfo("Updating IP resolution of [%s].\n",map_ip_str);
|
||||
|
@ -351,7 +351,7 @@ void do_init_irc(void)
|
||||
return;
|
||||
if (irc_ip_str[strlen(irc_ip_str)-1] == '\n')
|
||||
irc_ip_str[strlen(irc_ip_str)-1] = '\0';
|
||||
irc_ip = resolve_hostbyname(irc_ip_str, NULL, irc_ip_str);
|
||||
irc_ip = host2ip(irc_ip_str);
|
||||
if (!irc_ip)
|
||||
{
|
||||
ShowError("Unable to resolve %s! Cannot connect to IRC server, disabling irc_bot.\n", irc_ip_str);
|
||||
|
@ -3228,13 +3228,14 @@ void map_versionscreen(int flag) {
|
||||
|
||||
/*======================================================
|
||||
* Map-Server Init and Command-line Arguments [Valaris]
|
||||
*------------------------------------------------------
|
||||
*/
|
||||
*------------------------------------------------------*/
|
||||
void set_server_type(void)
|
||||
{
|
||||
SERVER_TYPE = ATHENA_SERVER_MAP;
|
||||
}
|
||||
int do_init(int argc, char *argv[]) {
|
||||
|
||||
int do_init(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
#ifdef GCOLLECT
|
||||
@ -3284,24 +3285,22 @@ int do_init(int argc, char *argv[]) {
|
||||
chrif_checkdefaultlogin();
|
||||
|
||||
if (!map_ip_set || !char_ip_set) {
|
||||
// The map server should know what IP address it is running on
|
||||
// - MouseJstr
|
||||
int localaddr = ntohl(addr_[0]);
|
||||
unsigned char *ptr = (unsigned char *) &localaddr;
|
||||
char buf[16];
|
||||
if (naddr_ == 0) {
|
||||
ShowError("\nUnable to determine your IP address... please edit the map_athena.conf file and set it.\n");
|
||||
ShowError("(127.0.0.1 is valid if you have no network interface)\n");
|
||||
}
|
||||
sprintf(buf, "%d.%d.%d.%d", ptr[0], ptr[1], ptr[2], ptr[3]);;
|
||||
if (naddr_ != 1)
|
||||
ShowNotice("Multiple interfaces detected.. using %s as our IP address\n", buf);
|
||||
else
|
||||
ShowInfo("Defaulting to %s as our IP address\n", buf);
|
||||
char ip_str[16];
|
||||
ip2str(addr_[0], ip_str);
|
||||
|
||||
ShowError("\nNot all IP addresses in map_athena.conf configured, autodetecting...\n");
|
||||
|
||||
if (naddr_ == 0)
|
||||
ShowError("Unable to determine your IP address...\n");
|
||||
else if (naddr_ > 1)
|
||||
ShowNotice("Multiple interfaces detected...\n");
|
||||
|
||||
ShowInfo("Defaulting to %s as our IP address\n", ip_str);
|
||||
|
||||
if (!map_ip_set)
|
||||
clif_setip(buf);
|
||||
clif_setip(ip_str);
|
||||
if (!char_ip_set)
|
||||
chrif_setip(buf);
|
||||
chrif_setip(ip_str);
|
||||
}
|
||||
|
||||
if (SHOW_DEBUG_MSG)
|
||||
@ -3375,17 +3374,3 @@ int do_init(int argc, char *argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int compare_item(struct item *a, struct item *b) {
|
||||
|
||||
if (a->nameid == b->nameid &&
|
||||
a->identify == b->identify &&
|
||||
a->refine == b->refine &&
|
||||
a->attribute == b->attribute)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < MAX_SLOTS && (a->card[i] == b->card[i]); i++);
|
||||
return (i == MAX_SLOTS);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1349,7 +1349,6 @@ void map_foreachpc(int (*func)(DBKey,void*,va_list),...);
|
||||
int map_foreachiddb(int (*)(DBKey,void*,va_list),...);
|
||||
void map_addnickdb(struct map_session_data *);
|
||||
struct map_session_data * map_nick2sd(const char*);
|
||||
int compare_item(struct item *a, struct item *b);
|
||||
char *map_normalize_name(char *mapname);
|
||||
|
||||
// その他
|
||||
|
@ -41,13 +41,13 @@ int storage_comp_item(const void *_i1, const void *_i2)
|
||||
return i1->nameid - i2->nameid;
|
||||
}
|
||||
|
||||
void sortage_sortitem (struct storage *stor)
|
||||
void storage_sortitem (struct storage *stor)
|
||||
{
|
||||
nullpo_retv(stor);
|
||||
qsort(stor->storage_, MAX_STORAGE, sizeof(struct item), storage_comp_item);
|
||||
}
|
||||
|
||||
void sortage_gsortitem (struct guild_storage* gstor)
|
||||
void storage_gsortitem (struct guild_storage* gstor)
|
||||
{
|
||||
nullpo_retv(gstor);
|
||||
qsort(gstor->storage_, MAX_GUILD_STORAGE, sizeof(struct item), storage_comp_item);
|
||||
@ -158,6 +158,21 @@ int storage_storageopen(struct map_session_data *sd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// helper function
|
||||
int compare_item(struct item *a, struct item *b) {
|
||||
|
||||
if (a->nameid == b->nameid &&
|
||||
a->identify == b->identify &&
|
||||
a->refine == b->refine &&
|
||||
a->attribute == b->attribute)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < MAX_SLOTS && (a->card[i] == b->card[i]); i++);
|
||||
return (i == MAX_SLOTS);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
* Internal add-item function.
|
||||
*------------------------------------------
|
||||
@ -452,7 +467,7 @@ int storage_storage_saved(int account_id)
|
||||
if (stor->dirty && stor->storage_status == 0)
|
||||
{ //Only mark it clean if it's not in use. [Skotlex]
|
||||
stor->dirty = 0;
|
||||
sortage_sortitem(stor);
|
||||
storage_sortitem(stor);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@ -716,7 +731,7 @@ int storage_guild_storagesaved(int guild_id)
|
||||
if (stor->dirty && stor->storage_status == 0)
|
||||
{ //Storage has been correctly saved.
|
||||
stor->dirty = 0;
|
||||
sortage_gsortitem(stor);
|
||||
storage_gsortitem(stor);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user