summaryrefslogtreecommitdiff
path: root/src/char/char.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/char/char.c')
-rw-r--r--src/char/char.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 09d8dbcc6..d7f7749c4 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -2032,31 +2032,38 @@ void loginif_on_ready(void)
}
-int parse_fromlogin(int fd)
-{
+int parse_fromlogin(int fd) {
struct char_session_data* sd = NULL;
int i;
// only process data from the login-server
- if( fd != login_fd )
- {
+ if( fd != login_fd ) {
ShowDebug("parse_fromlogin: Disconnecting invalid session #%d (is not the login-server)\n", fd);
do_close(fd);
return 0;
}
- if( session[fd]->flag.eof )
- {
+ if( session[fd]->flag.eof ) {
do_close(fd);
login_fd = -1;
loginif_on_disconnect();
return 0;
+ } else if ( session[fd]->flag.ping ) {/* we've reached stall time */
+ if( DIFF_TICK(last_tick, session[fd]->rdata_tick) > (stall_time * 2) ) {/* we can't wait any longer */
+ set_eof(fd);
+ return 0;
+ } else if( session[fd]->flag.ping != 2 ) { /* we haven't sent ping out yet */
+ WFIFOHEAD(fd,2);// sends a ping packet to login server (will receive pong 0x2718)
+ WFIFOW(fd,0) = 0x2719;
+ WFIFOSET(fd,2);
+
+ session[fd]->flag.ping = 2;
+ }
}
sd = (struct char_session_data*)session[fd]->session_data;
- while(RFIFOREST(fd) >= 2)
- {
+ while(RFIFOREST(fd) >= 2) {
uint16 command = RFIFOW(fd,0);
switch( command )
@@ -2164,6 +2171,7 @@ int parse_fromlogin(int fd)
if (RFIFOREST(fd) < 2)
return 0;
RFIFOSKIP(fd,2);
+ session[fd]->flag.ping = 0;
break;
// changesex reply
@@ -2357,7 +2365,6 @@ int parse_fromlogin(int fd)
}
int check_connect_login_server(int tid, unsigned int tick, int id, intptr_t data);
-int ping_login_server(int tid, unsigned int tick, int id, intptr_t data);
int send_accounts_tologin(int tid, unsigned int tick, int id, intptr_t data);
void do_init_loginif(void)
@@ -2365,11 +2372,7 @@ void do_init_loginif(void)
// establish char-login connection if not present
add_timer_func_list(check_connect_login_server, "check_connect_login_server");
add_timer_interval(gettick() + 1000, check_connect_login_server, 0, 0, 10 * 1000);
-
- // keep the char-login connection alive
- add_timer_func_list(ping_login_server, "ping_login_server");
- add_timer_interval(gettick() + 1000, ping_login_server, 0, 0, ((int)stall_time-2) * 1000);
-
+
// send a list of all online account IDs to login server
add_timer_func_list(send_accounts_tologin, "send_accounts_tologin");
add_timer_interval(gettick() + 1000, send_accounts_tologin, 0, 0, 3600 * 1000); //Sync online accounts every hour
@@ -4299,18 +4302,6 @@ int check_connect_login_server(int tid, unsigned int tick, int id, intptr_t data
return 1;
}
-// sends a ping packet to login server (will receive pong 0x2718)
-int ping_login_server(int tid, unsigned int tick, int id, intptr_t data)
-{
- if (login_fd > 0 && session[login_fd] != NULL)
- {
- WFIFOHEAD(login_fd,2);
- WFIFOW(login_fd,0) = 0x2719;
- WFIFOSET(login_fd,2);
- }
- return 0;
-}
-
//------------------------------------------------
//Invoked 15 seconds after mapif_disconnectplayer in case the map server doesn't
//replies/disconnect the player we tried to kick. [Skotlex]