summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/chrif.c12
-rw-r--r--src/map/chrif.h2
-rw-r--r--src/map/clif.c18
-rw-r--r--src/map/irc.c2
-rw-r--r--src/map/map.c51
-rw-r--r--src/map/map.h1
-rw-r--r--src/map/storage.c23
7 files changed, 54 insertions, 55 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 403cfdcb1..d432320d3 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -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
diff --git a/src/map/chrif.h b/src/map/chrif.h
index a80543d1a..92a719929 100644
--- a/src/map/chrif.h
+++ b/src/map/chrif.h
@@ -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);
diff --git a/src/map/clif.c b/src/map/clif.c
index a9214a137..4844f0ac5 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -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);
diff --git a/src/map/irc.c b/src/map/irc.c
index 8760efc11..c5e707dd9 100644
--- a/src/map/irc.c
+++ b/src/map/irc.c
@@ -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);
diff --git a/src/map/map.c b/src/map/map.c
index 9cf047d56..a28ac20c5 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -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;
-}
diff --git a/src/map/map.h b/src/map/map.h
index a6f0cf614..244bc18b3 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -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);
// ‚»‚Ì‘¼
diff --git a/src/map/storage.c b/src/map/storage.c
index 4d652903b..12d5b5696 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -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;
}