summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-04-05 18:49:57 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-04-05 18:49:57 +0000
commit88a5d0cdda513357496b9d53878618e1620f47e8 (patch)
tree4f3c2bedbac4b715ff783de5e1c8d1aefe4395af /src/map
parenta7fd6bfe9bcce1862b554f5841d9ff1aedf473e3 (diff)
downloadhercules-88a5d0cdda513357496b9d53878618e1620f47e8.tar.gz
hercules-88a5d0cdda513357496b9d53878618e1620f47e8.tar.bz2
hercules-88a5d0cdda513357496b9d53878618e1620f47e8.tar.xz
hercules-88a5d0cdda513357496b9d53878618e1620f47e8.zip
* Made a crazy attempt to at least partially synchronize login&char code
* Major edit to the way the servers handle ip addresses, making them obey the "host byte order inside, network byte order outside" rule - hopefully covered all entry- and exit-points for IP address data - discovered several places where Gravity's client breaks the convention, will need to come up with a suitable countermeasure for that - other than that, the code should be portable, except for printing and ipban mask testing (those still assume a specific byte order) - tested both txt and sql in all usual situations; tested single- and multi-server setups, all seems to work (but watch out for hidden bugs!) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10162 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/chrif.c147
-rw-r--r--src/map/chrif.h12
-rw-r--r--src/map/clif.c51
-rw-r--r--src/map/clif.h10
-rw-r--r--src/map/map.c21
-rw-r--r--src/map/map.h10
-rw-r--r--src/map/pc.c15
7 files changed, 111 insertions, 155 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c
index d432320d3..8596ad2f2 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -24,18 +24,14 @@
#include "status.h"
#include "mercenary.h"
-//Updated table (only doc^^) [Sirius]
-//Used Packets: U->2af8
-//Free Packets: F->2af8
-
struct dbt *auth_db;
-static const int packet_len_table[0x3d] = {
+static const int packet_len_table[0x3d] = { // U - used, F - free
60, 3,-1,27,10,-1, 6,-1, // 2af8-2aff: U->2af8, U->2af9, U->2afa, U->2afb, U->2afc, U->2afd, U->2afe, U->2aff
6,-1,18, 7,-1,49,30,10, // 2b00-2b07: U->2b00, U->2b01, U->2b02, U->2b03, U->2b04, U->2b05, U->2b06, U->2b07
6,30,-1,10,86, 7,44,34, // 2b08-2b0f: U->2b08, U->2b09, U->2b0a, U->2b0b, U->2b0c, U->2b0d, U->2b0e, U->2b0f
0,-1,10, 6,11,-1, 0, 0, // 2b10-2b17: U->2b10, U->2b11, U->2b12, U->2b13, U->2b14, U->2b15, U->2b16, U->2b17
- -1,-1,-1,-1,-1,-1, 2, 7, // 2b18-2b1f: U->2b18, U->2b19, U->2b1a, U->2b1b, U->2b1c, U->2b1d, U->2b1e, U->2b1f
+ -1,-1,-1,-1,-1,-1, 2, 7, // 2b18-2b1f: U->2b18, U->2b19, U->2b1a, U->2b1b, U->2b1c, U->2b1d, U->2b1e, U->2b1f
-1,10, 8,-1,-1,-1,-1,-1, // 2b20-2b27: U->2b20, U->2b21, U->2b22, U->2b23, F->2b24, F->2b25, F->2b26, F->2b27
};
@@ -89,8 +85,8 @@ int chrif_connected = 0;
int char_fd = 0; //Using 0 instead of -1 is safer against crashes. [Skotlex]
int srvinfo;
static char char_ip_str[128];
-static in_addr_t char_ip= 0;
-static int char_port = 6121;
+static uint32 char_ip = 0;
+static uint16 char_port = 6121;
static char userid[NAME_LENGTH], passwd[NAME_LENGTH];
static int chrif_state = 0;
static int char_init_done = 0;
@@ -103,29 +99,20 @@ int other_mapserver_count=0; //Holds count of how many other map servers are onl
//This define should spare writing the check in every function. [Skotlex]
#define chrif_check(a) { if(!chrif_isconnect()) return a; }
-// 設定ファイル読み込み関係
-/*==========================================
- *
- *------------------------------------------
- */
+
+// sets char-server's user id
void chrif_setuserid(char *id)
{
memcpy(userid, id, NAME_LENGTH);
}
-/*==========================================
- *
- *------------------------------------------
- */
+// sets char-server's password
void chrif_setpasswd(char *pwd)
{
memcpy(passwd, pwd, NAME_LENGTH);
}
-/*==========================================
- *
- *------------------------------------------
- */
+// security check, prints warning if using default password
void chrif_checkdefaultlogin(void)
{
if (strcmp(userid, "s1")==0 && strcmp(passwd, "p1")==0) {
@@ -139,11 +126,8 @@ void chrif_checkdefaultlogin(void)
}
}
-/*==========================================
- *
- *------------------------------------------
- */
-int chrif_setip(const char *ip)
+// sets char-server's ip address
+int chrif_setip(const char* ip)
{
char ip_str[16];
char_ip = host2ip(ip);
@@ -156,30 +140,23 @@ int chrif_setip(const char *ip)
return 1;
}
-/*==========================================
- *
- *------------------------------------------
- */
-void chrif_setport(int port)
+// sets char-server's port number
+void chrif_setport(uint16 port)
{
char_port = port;
}
-/*==========================================
- *
- *------------------------------------------
- */
+// says whether the char-server is connected or not
int chrif_isconnect(void)
{
return (char_fd > 0 && session[char_fd] != NULL && chrif_state == 2);
}
/*==========================================
- * Saves char.
- * Flag = 1: Character is quitting.
+ * Saves character data.
+ * Flag = 1: Character is quitting
* Flag = 2: Character is changing map-servers
- *------------------------------------------
- */
+ *------------------------------------------*/
int chrif_save(struct map_session_data *sd, int flag)
{
nullpo_retr(-1, sd);
@@ -226,10 +203,7 @@ int chrif_save(struct map_session_data *sd, int flag)
return 0;
}
-/*==========================================
- *
- *------------------------------------------
- */
+// connects to char-server (plaintext)
int chrif_connect(int fd)
{
ShowStatus("Logging in to char server...\n", char_fd);
@@ -238,17 +212,14 @@ 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_long();
- WFIFOW(fd,58) = clif_getport(); // [Valaris] thanks to fov
+ WFIFOL(fd,54) = htonl(clif_getip());
+ WFIFOW(fd,58) = htons(clif_getport());
WFIFOSET(fd,60);
return 0;
}
-/*==========================================
- * マップ送信
- *------------------------------------------
- */
+// sends maps to char-server
int chrif_sendmap(int fd)
{
int i;
@@ -263,36 +234,31 @@ int chrif_sendmap(int fd)
return 0;
}
-/*==========================================
- * マップ受信
- *------------------------------------------
- */
+// receive maps from some other map-server (relayed via char-server)
int chrif_recvmap(int fd)
{
- int i, j, ip, port;
- unsigned char *p = (unsigned char *)&ip;
+ int i, j;
+ uint32 ip;
+ uint16 port;
RFIFOHEAD(fd);
- ip = RFIFOL(fd,4);
- port = RFIFOW(fd,8);
+ ip = ntohl(RFIFOL(fd,4));
+ port = ntohs(RFIFOW(fd,8));
for(i = 10, j = 0; i < RFIFOW(fd,2); i += 4, j++) {
map_setipport(RFIFOW(fd,i), ip, port);
-// if (battle_config.etc_log)
-// printf("recv map %d %s\n", j, RFIFOP(fd,i));
}
if (battle_config.etc_log)
- ShowStatus("recv map on %d.%d.%d.%d:%d (%d maps)\n", p[0], p[1], p[2], p[3], port, j);
+ ShowStatus("Received maps from %d.%d.%d.%d:%d (%d maps)\n", CONVIP(ip), port, j);
other_mapserver_count++;
return 0;
}
-/*==========================================
- * Delete maps of other servers, (if an other mapserver is going OFF)
- *------------------------------------------
- */
-int chrif_removemap(int fd){
- int i, j, ip, port;
- unsigned char *p = (unsigned char *)&ip;
+// remove specified maps (used when some other map-server disconnects)
+int chrif_removemap(int fd)
+{
+ int i, j;
+ uint32 ip;
+ uint16 port;
RFIFOHEAD(fd);
ip = RFIFOL(fd, 4);
@@ -304,11 +270,13 @@ int chrif_removemap(int fd){
other_mapserver_count--;
if(battle_config.etc_log)
- ShowStatus("remove map of server %d.%d.%d.%d:%d (%d maps)\n", p[0], p[1], p[2], p[3], port, j);
+ ShowStatus("remove map of server %d.%d.%d.%d:%d (%d maps)\n", CONVIP(ip), port, j);
return 0;
}
-int chrif_save_ack(int fd) {
+// received after a character has been "final saved" on the char-server
+int chrif_save_ack(int fd)
+{
struct map_session_data *sd;
RFIFOHEAD(fd);
sd = map_id2sd(RFIFOL(fd,2));
@@ -318,13 +286,10 @@ int chrif_save_ack(int fd) {
return 0;
}
-/*==========================================
- * マップ鯖間移動のためのデータ準備要求
- *------------------------------------------
- */
-int chrif_changemapserver(struct map_session_data *sd, short map, int x, int y, int ip, short port)
+// request to move a character between mapservers
+int chrif_changemapserver(struct map_session_data *sd, short map, int x, int y, uint32 ip, uint16 port)
{
- int s_ip;
+ uint32 s_ip;
nullpo_retr(-1, sd);
@@ -337,7 +302,7 @@ int chrif_changemapserver(struct map_session_data *sd, short map, int x, int y,
}
if (sd->fd && sd->fd < fd_max && session[sd->fd])
- s_ip = session[sd->fd]->client_addr.sin_addr.s_addr;
+ s_ip = session[sd->fd]->client_addr;
else //Not connected? Can't retrieve IP
s_ip = 0;
@@ -350,19 +315,16 @@ int chrif_changemapserver(struct map_session_data *sd, short map, int x, int y,
WFIFOW(char_fd,18) = map;
WFIFOW(char_fd,20) = x;
WFIFOW(char_fd,22) = y;
- WFIFOL(char_fd,24) = ip;
- WFIFOW(char_fd,28) = port;
+ WFIFOL(char_fd,24) = htonl(ip);
+ WFIFOW(char_fd,28) = htons(port);
WFIFOB(char_fd,30) = sd->status.sex;
- WFIFOL(char_fd,31) = s_ip;
+ WFIFOL(char_fd,31) = htonl(s_ip); // not used
WFIFOSET(char_fd,35);
return 0;
}
-/*==========================================
- * マップ鯖間移動ack
- *------------------------------------------
- */
+// map-server change request acknowledgement (positive or negative)
int chrif_changemapserverack(int fd)
{
struct map_session_data *sd;
@@ -380,7 +342,7 @@ int chrif_changemapserverack(int fd)
return 0;
}
sprintf(mapname, "%s.gat", mapindex_id2name(RFIFOW(fd,18)));
- clif_changemapserver(sd, mapname, RFIFOW(fd,20), RFIFOW(fd,22), RFIFOL(fd,24), RFIFOW(fd,28));
+ clif_changemapserver(sd, mapname, RFIFOW(fd,20), RFIFOW(fd,22), ntohl(RFIFOL(fd,24)), ntohs(RFIFOW(fd,28)));
//Player has been saved already, remove him from memory. [Skotlex]
map_quit(sd);
@@ -390,8 +352,7 @@ int chrif_changemapserverack(int fd)
/*==========================================
*
- *------------------------------------------
- */
+ *------------------------------------------*/
int chrif_connectack(int fd)
{
RFIFOHEAD(fd);
@@ -568,7 +529,7 @@ int auth_db_cleanup(int tid, unsigned int tick, int id, int data) {
*
*------------------------------------------
*/
-int chrif_charselectreq(struct map_session_data *sd, unsigned long s_ip)
+int chrif_charselectreq(struct map_session_data* sd, uint32 s_ip)
{
nullpo_retr(-1, sd);
@@ -581,7 +542,7 @@ int chrif_charselectreq(struct map_session_data *sd, unsigned long s_ip)
WFIFOL(char_fd, 2) = sd->bl.id;
WFIFOL(char_fd, 6) = sd->login_id1;
WFIFOL(char_fd,10) = sd->login_id2;
- WFIFOL(char_fd,14) = s_ip;
+ WFIFOL(char_fd,14) = htonl(s_ip);
WFIFOSET(char_fd,18);
return 0;
@@ -693,7 +654,6 @@ int chrif_changesex(int id, int sex) {
WFIFOW(char_fd,2) = 9;
WFIFOL(char_fd,4) = id;
WFIFOB(char_fd,8) = sex;
-// ShowInfo("chrif : sent 0x3000(changesex)\n");
WFIFOSET(char_fd,9);
return 0;
}
@@ -1040,7 +1000,8 @@ int chrif_accountban(int fd)
//Disconnect the player out of the game, simple packet
//packet.w AID.L WHY.B 2+4+1 = 7byte
-int chrif_disconnectplayer(int fd){
+int chrif_disconnectplayer(int fd)
+{
struct map_session_data *sd;
RFIFOHEAD(fd);
@@ -1419,7 +1380,7 @@ int chrif_disconnect(int fd) {
void chrif_update_ip(int fd)
{
- unsigned long new_ip;
+ uint32 new_ip;
WFIFOHEAD(fd, 6);
new_ip = host2ip(char_ip_str);
if (new_ip && new_ip != char_ip)
@@ -1428,7 +1389,7 @@ void chrif_update_ip(int fd)
new_ip = clif_refresh_ip();
if (!new_ip) return; //No change
WFIFOW(fd, 0) = 0x2736;
- WFIFOL(fd, 2) = new_ip;
+ WFIFOL(fd, 2) = htonl(new_ip);
WFIFOSET(fd, 6);
}
@@ -1452,7 +1413,7 @@ int chrif_parse(int fd)
return 0;
}
- while (RFIFOREST(fd) >= 2 && !session[fd]->eof) { //Infinite loop on broken pipe fix. [Skotlex]
+ while (RFIFOREST(fd) >= 2) { //Infinite loop on broken pipe fix. [Skotlex]
RFIFOHEAD(fd);
cmd = RFIFOW(fd,0);
if (cmd < 0x2af8 || cmd >= 0x2af8 + (sizeof(packet_len_table) / sizeof(packet_len_table[0])) ||
diff --git a/src/map/chrif.h b/src/map/chrif.h
index 92a719929..adbf0ab2f 100644
--- a/src/map/chrif.h
+++ b/src/map/chrif.h
@@ -12,11 +12,11 @@ struct auth_node{
unsigned int node_created; //For node auto-deleting
};
-void chrif_setuserid(char*);
-void chrif_setpasswd(char*);
+void chrif_setuserid(char* id);
+void chrif_setpasswd(char* pwd);
void chrif_checkdefaultlogin(void);
-int chrif_setip(const char*);
-void chrif_setport(int);
+int chrif_setip(const char* ip);
+void chrif_setport(uint16 port);
int chrif_isconnect(void);
@@ -27,9 +27,9 @@ void chrif_authreq(struct map_session_data *);
void chrif_authok(int fd);
int chrif_scdata_request(int account_id, int char_id);
int chrif_save(struct map_session_data*, int flag);
-int chrif_charselectreq(struct map_session_data *sd, unsigned long s_ip);
+int chrif_charselectreq(struct map_session_data*sd, uint32 s_ip);
void check_fake_id(int fd, struct map_session_data *sd, int target_id);
-int chrif_changemapserver(struct map_session_data *sd,short map,int x,int y,int ip,short port);
+int chrif_changemapserver(struct map_session_data*sd, short map, int x, int y, uint32 ip, uint16 port);
int chrif_searchcharid(int char_id);
int chrif_changegm(int id,const char *pass,int len);
diff --git a/src/map/clif.c b/src/map/clif.c
index 366fdbec9..fdba61dba 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -96,9 +96,9 @@ struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB];
//Guarantees that the given string does not exceeds the allowed size, as well as making sure it's null terminated. [Skotlex\]
#define mes_len_check(mes, len, max) if (len > max) { mes[max-1] = '\0'; len = max; } else mes[len-1] = '\0';
static char map_ip_str[128];
-static in_addr_t map_ip;
-static in_addr_t bind_ip = INADDR_ANY;
-static int map_port = 5121;
+static uint32 map_ip;
+static uint32 bind_ip = INADDR_ANY;
+static uint16 map_port = 5121;
int map_fd;
//These two will be used to verify the incoming player's validity.
@@ -142,7 +142,7 @@ void clif_setbindip(const char* ip)
* map鯖のport設定
*------------------------------------------
*/
-void clif_setport(int port)
+void clif_setport(uint16 port)
{
map_port = port;
}
@@ -151,27 +151,21 @@ void clif_setport(int port)
* map鯖のip読み出し
*------------------------------------------
*/
-in_addr_t clif_getip(void)
+uint32 clif_getip(void)
{
return map_ip;
}
-//Returns the ip casted as a basic type, to avoid needing to include the socket/net related libs by calling modules.
-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)
+uint32 clif_refresh_ip(void)
{
- in_addr_t new_ip;
+ uint32 new_ip;
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);
- return (unsigned long)map_ip;
+ ShowInfo("Updating IP resolution of [%s].\n", map_ip_str);
+ return map_ip;
}
return 0;
}
@@ -180,7 +174,7 @@ unsigned long clif_refresh_ip(void)
* map鯖のport読み出し
*------------------------------------------
*/
-int clif_getport(void)
+uint16 clif_getport(void)
{
return map_port;
}
@@ -1625,10 +1619,10 @@ int clif_changemap(struct map_session_data *sd, short map, int x, int y) {
}
/*==========================================
- *
- *------------------------------------------
- */
-int clif_changemapserver(struct map_session_data* sd, const char* mapname, int x, int y, int ip, int port) {
+ * Tells the client to connect to another map-server
+ *------------------------------------------*/
+int clif_changemapserver(struct map_session_data* sd, const char* mapname, int x, int y, uint32 ip, uint16 port)
+{
int fd;
nullpo_retr(0, sd);
@@ -1641,8 +1635,8 @@ int clif_changemapserver(struct map_session_data* sd, const char* mapname, int x
WFIFOB(fd,17) = 0; //Null terminator for mapname
WFIFOW(fd,18) = x;
WFIFOW(fd,20) = y;
- WFIFOL(fd,22) = ip;
- WFIFOW(fd,26) = port;
+ WFIFOL(fd,22) = htonl(ip);
+ WFIFOW(fd,26) = port; // /!\ must be sent in intel host byte order /!\ (client bug)
WFIFOSET(fd, packet_len(0x92));
return 0;
@@ -8862,7 +8856,7 @@ void clif_parse_Restart(int fd, struct map_session_data *sd) {
/* Rovert's Prevent logout option - Fixed [Valaris] */
if (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout)
{ //Send to char-server for character selection.
- chrif_charselectreq(sd, session[fd]->client_addr.sin_addr.s_addr);
+ chrif_charselectreq(sd, session[fd]->client_addr);
} else {
WFIFOHEAD(fd,packet_len(0x18b));
WFIFOW(fd,0)=0x18b;
@@ -11746,7 +11740,8 @@ void clif_parse_debug(int fd,struct map_session_data *sd)
* socket.cのdo_parsepacketから呼び出される
*------------------------------------------
*/
-int clif_parse(int fd) {
+int clif_parse(int fd)
+{
int packet_len = 0, cmd, packet_ver, err, dump = 0;
TBL_PC *sd;
RFIFOHEAD(fd);
@@ -11772,8 +11767,8 @@ int clif_parse(int fd) {
map_quit(sd);
}
} else {
- unsigned char *ip = (unsigned char *) &session[fd]->client_addr.sin_addr;
- ShowInfo("Closed connection from '"CL_WHITE"%d.%d.%d.%d"CL_RESET"'.\n", ip[0],ip[1],ip[2],ip[3]);
+ uint32 ip = session[fd]->client_addr;
+ ShowInfo("Closed connection from '"CL_WHITE"%d.%d.%d.%d"CL_RESET"'.\n", CONVIP(ip));
}
do_close(fd);
return 0;
@@ -12321,8 +12316,8 @@ static int packetdb_readdb(void)
*
*------------------------------------------
*/
-int do_init_clif(void) {
-
+int do_init_clif(void)
+{
clif_config.packet_db_ver = -1; // the main packet version of the DB
memset(clif_config.connect_cmd, 0, sizeof(clif_config.connect_cmd)); //The default connect command will be determined after reading the packet_db [Skotlex]
diff --git a/src/map/clif.h b/src/map/clif.h
index c9e48c986..af5bcdd8d 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -52,11 +52,11 @@ extern struct packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB];
int clif_setip(const char* ip);
void clif_setbindip(const char* ip);
-void clif_setport(int);
+void clif_setport(uint16 port);
-unsigned long clif_getip_long(void);
-unsigned long clif_refresh_ip(void);
-int clif_getport(void);
+uint32 clif_getip(void);
+uint32 clif_refresh_ip(void);
+uint16 clif_getport(void);
int clif_countusers(void);
void clif_setwaitclose(int);
@@ -75,7 +75,7 @@ int clif_spawn(struct block_list*); //area
int clif_walkok(struct map_session_data*); // self
void clif_move(struct unit_data *ud); //area
int clif_changemap(struct map_session_data*,short,int,int); //self
-int clif_changemapserver(struct map_session_data* sd, const char* mapname, int x, int y, int ip, int port); //self
+int clif_changemapserver(struct map_session_data* sd, const char* mapname, int x, int y, uint32 ip, uint16 port); //self
int clif_blown(struct block_list *); // area
int clif_slide(struct block_list *,int,int); // area
int clif_fixpos(struct block_list *); // area
diff --git a/src/map/map.c b/src/map/map.c
index a28ac20c5..4c38c3754 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -2077,9 +2077,9 @@ int map_mapindex2mapid(unsigned short mapindex) {
/*==========================================
* 他鯖map名からip,port?換
- *------------------------------------------
- */
-int map_mapname2ipport(unsigned short name,int *ip,int *port) {
+ *------------------------------------------*/
+int map_mapname2ipport(unsigned short name, uint32* ip, uint16* port)
+{
struct map_data_other_server *mdos=NULL;
mdos = (struct map_data_other_server*)uidb_get(map_db,(unsigned int)name);
@@ -2349,16 +2349,17 @@ static void* create_map_data_other_server(DBKey key, va_list args) {
}
/*==========================================
* 他鯖管理のマップをdbに追加
- *------------------------------------------
- */
-int map_setipport(unsigned short mapindex,unsigned long ip,int port) {
+ *------------------------------------------*/
+
+int map_setipport(unsigned short mapindex, uint32 ip, uint16 port)
+{
struct map_data_other_server *mdos=NULL;
mdos=(struct map_data_other_server *)uidb_ensure(map_db,(unsigned int)mapindex, create_map_data_other_server);
if(mdos->gat) //Local map,Do nothing. Give priority to our own local maps over ones from another server. [Skotlex]
return 0;
- if(ip == clif_getip_long() && port == clif_getport()) {
+ if(ip == clif_getip() && port == clif_getport()) {
//That's odd, we received info that we are the ones with this map, but... we don't have it.
ShowFatalError("map_setipport : received info that this map-server SHOULD have map '%s', but it is not loaded.\n",mapindex_id2name(mapindex));
exit(1);
@@ -2388,12 +2389,10 @@ int map_eraseallipport(void) {
/*==========================================
* 他鯖管理のマップをdbから削除
- *------------------------------------------
- */
-int map_eraseipport(unsigned short mapindex,unsigned long ip,int port)
+ *------------------------------------------*/
+int map_eraseipport(unsigned short mapindex, uint32 ip, uint16 port)
{
struct map_data_other_server *mdos;
-// unsigned char *p=(unsigned char *)&ip;
mdos = uidb_get(map_db,(unsigned int)mapindex);
if(!mdos || mdos->gat) //Map either does not exists or is a local map.
diff --git a/src/map/map.h b/src/map/map.h
index 2e433c619..96b2b79b8 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -1109,8 +1109,8 @@ struct map_data_other_server {
char name[MAP_NAME_LENGTH];
unsigned short index; //Index is the map index used by the mapindex* functions.
unsigned char *gat; // NULL固定にして判断
- unsigned long ip;
- unsigned int port;
+ uint32 ip;
+ uint16 port;
};
struct flooritem_data {
@@ -1339,9 +1339,9 @@ struct map_session_data * map_id2sd(int);
struct block_list * map_id2bl(int);
int map_mapindex2mapid(unsigned short mapindex);
int map_mapname2mapid(const char* name);
-int map_mapname2ipport(unsigned short,int*,int*);
-int map_setipport(unsigned short map,unsigned long ip,int port);
-int map_eraseipport(unsigned short map,unsigned long ip,int port);
+int map_mapname2ipport(unsigned short name, uint32* ip, uint16* port);
+int map_setipport(unsigned short map, uint32 ip, uint16 port);
+int map_eraseipport(unsigned short map, uint32 ip, uint16 port);
int map_eraseallipport(void);
void map_addiddb(struct block_list *);
void map_deliddb(struct block_list *bl);
diff --git a/src/map/pc.c b/src/map/pc.c
index 7ba8a8b87..24088ff61 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -698,20 +698,20 @@ int pc_authok(struct map_session_data *sd, int login_id2, time_t connect_until_t
sd->state.event_kill_mob = 1;
{ //Add IP field
- unsigned char *ip = (unsigned char *) &session[sd->fd]->client_addr.sin_addr;
+ uint32 ip = session[sd->fd]->client_addr;
if (pc_isGM(sd))
ShowInfo("GM '"CL_WHITE"%s"CL_RESET"' logged in."
" (AID/CID: '"CL_WHITE"%d/%d"CL_RESET"',"
" Packet Ver: '"CL_WHITE"%d"CL_RESET"', IP: '"CL_WHITE"%d.%d.%d.%d"CL_RESET"',"
" GM Level '"CL_WHITE"%d"CL_RESET"').\n",
sd->status.name, sd->status.account_id, sd->status.char_id,
- sd->packet_ver, ip[0],ip[1],ip[2],ip[3], pc_isGM(sd));
+ sd->packet_ver, CONVIP(ip), pc_isGM(sd));
else
ShowInfo("'"CL_WHITE"%s"CL_RESET"' logged in."
" (AID/CID: '"CL_WHITE"%d/%d"CL_RESET"',"
" Packet Ver: '"CL_WHITE"%d"CL_RESET"', IP: '"CL_WHITE"%d.%d.%d.%d"CL_RESET"').\n",
sd->status.name, sd->status.account_id, sd->status.char_id,
- sd->packet_ver, ip[0],ip[1],ip[2],ip[3]);
+ sd->packet_ver, CONVIP(ip));
}
// Send friends list
@@ -3371,10 +3371,11 @@ int pc_setpos(struct map_session_data *sd,unsigned short mapindex,int x,int y,in
sd->regen.state.gc = 0;
}
- if(m<0){
- if(sd->mapindex){
- int ip,port;
- if(map_mapname2ipport(mapindex,&ip,&port)==0){
+ if(m<0) {
+ if(sd->mapindex) {
+ uint32 ip;
+ uint16 port;
+ if(map_mapname2ipport(mapindex,&ip,&port)==0) {
unit_remove_map(&sd->bl,clrtype);
sd->mapindex = mapindex;
sd->bl.x=x;