Browse Source

git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@785 54d463be-8e91-2dee-dedb-b68131a5f0ec

celest 20 years ago
parent
commit
8ffa2ba71e
4 changed files with 31 additions and 3 deletions
  1. 5 0
      Changelog.txt
  2. 22 2
      src/map/clif.c
  3. 1 0
      src/map/clif.h
  4. 3 1
      src/map/pc.c

+ 5 - 0
Changelog.txt

@@ -1,5 +1,9 @@
 Date	Added
 12/24
+        * Added suggested fix when client disconnected [celest]
+          - send "disconnected due to time gap" and close session when timed out
+          - send "server still recognises last login" message and close existing
+            session when client reconnects
 	* Upped windwalk to lv 10 in skill_tree [MouseJstr]
 	* Fixed a scripting crash (SVN: 781) [MouseJstr]
 	* removed @changesex and @charchangesex until we can
@@ -18,6 +22,7 @@ Date	Added
 		Note:	mes = otput into client's NPC window
 			debugmes = output into map-server window
 			logmes = output into lognpc log DB.
+
 12/23
 	* Fixed some bugs in the clif.c changes (SVN 766 to SVN 767) [MouseJstr]
 	* Added ayo monsters to @disguise

+ 22 - 2
src/map/clif.c

@@ -7104,6 +7104,25 @@ int clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd,int ty
 
 	return 0;
 }
+
+/*==========================================
+ *
+ *------------------------------------------
+ */
+
+int clif_timedout(struct map_session_data *sd) 
+{
+	nullpo_retr(0, sd);
+
+	sprintf(tmp_output,"%sCharacter with Account ID '"CL_WHITE"%d"CL_RESET"' timed out.\n", (pc_isGM(sd))?"GM ":"", sd->bl.id);
+	ShowInfo(tmp_output);
+	map_quit(sd);
+	clif_authfail_fd(sd->fd,3); // Even if player is not on we still send anyway
+	clif_setwaitclose(sd->fd); // Set session to EOF
+
+	return 0;
+}
+
 /*==========================================
  * Wis‹‘”Û‹–‰Â‰ž“š
  *------------------------------------------
@@ -7251,8 +7270,9 @@ void clif_parse_WantToConnection(int fd, struct map_session_data *sd)
 
 	// if same account already connected, we disconnect the 2 sessions
 	if ((old_sd = map_id2sd(account_id)) != NULL) {
-		clif_authfail_fd(fd, 2); // same id
+		clif_authfail_fd(fd, 8); // still recognizes last connection
 		clif_authfail_fd(old_sd->fd, 2); // same id
+		clif_setwaitclose(sd->fd); // Set session to EOF
 	} else {
 		sd = session[fd]->session_data = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data));
 		sd->fd = fd;
@@ -10234,7 +10254,7 @@ static int clif_parse(int fd) {
 	if (RFIFOREST(fd) < 2)
 		return 0;
 
-	//printf("clif_parse: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd));
+//	printf("clif_parse: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd));
 
 	cmd = RFIFOW(fd,0);
 

+ 1 - 0
src/map/clif.h

@@ -280,6 +280,7 @@ int clif_message(struct block_list *bl, char* msg); // messages (from mobs/npcs)
 
 int clif_GM_kickack(struct map_session_data *sd,int id);
 int clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd,int type);
+int clif_timedout(struct map_session_data *sd);
 
 int clif_foreachclient(int (*)(struct map_session_data*,va_list),...);
 

+ 3 - 1
src/map/pc.c

@@ -7853,7 +7853,9 @@ int pc_alive_timer(int tid,unsigned int tick,int id,int data)
 	nullpo_retr(0, sd);
 	if(sd->alive_timer != tid)
 		return 0;
-	map_quit(sd);
+//	map_quit(sd);
+	clif_timedout (sd);
+
 	return 0;
 }