Browse Source

- Added a cleanup routine on shutdown to remove all characters from memory for whom the save ack has not returned from the char-server yet.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@7923 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 19 years ago
parent
commit
36602a3958
2 changed files with 18 additions and 1 deletions
  1. 2 0
      Changelog-Trunk.txt
  2. 16 1
      src/map/map.c

+ 2 - 0
Changelog-Trunk.txt

@@ -4,6 +4,8 @@ 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.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 
 2006/07/27
 2006/07/27
+	* Added a cleanup routine on shutdown to remove all characters from memory
+	  for whom the save ack has not returned from the char-server yet. [Skotlex]
 	* Now when you set the guardian's HP, if the guardian is spawned, it's HP
 	* Now when you set the guardian's HP, if the guardian is spawned, it's HP
 	  will be updated accordingly (and if you set it to 0, the guardian is
 	  will be updated accordingly (and if you set it to 0, the guardian is
 	  killed) [Skotlex]
 	  killed) [Skotlex]

+ 16 - 1
src/map/map.c

@@ -3617,6 +3617,18 @@ static int cleanup_db_sub(DBKey key,void *data,va_list va) {
 	return cleanup_sub((struct block_list*)data, NULL);
 	return cleanup_sub((struct block_list*)data, NULL);
 }
 }
 
 
+static int cleanup_db_subpc(DBKey key,void *data,va_list va) {
+	struct map_session_data *sd = (TBL_PC*)data;
+	if (!sd->state.finalsave)
+  	{	//Error?
+		ShowError("do_final: Player character in DB which was not sent to save! %d:%d\n", sd->status.account_id, sd->status.char_id);
+		map_quit(sd); //Attempt force-save
+	}
+	//Force remove from memory...
+	map_quit_ack(sd);
+	return 1;
+}
+
 /*==========================================
 /*==========================================
  * mapŽI�I—¹�E—�
  * mapŽI�I—¹�E—�
  *------------------------------------------
  *------------------------------------------
@@ -3645,9 +3657,12 @@ void do_final(void) {
 	for (i = 0; i < j; i++)
 	for (i = 0; i < j; i++)
 		map_quit(pl_allsd[i]);
 		map_quit(pl_allsd[i]);
 		
 		
-	i = id_db->foreach(id_db,cleanup_db_sub);
+	id_db->foreach(id_db,cleanup_db_sub);
 	chrif_char_reset_offline();
 	chrif_char_reset_offline();
 	chrif_flush_fifo();
 	chrif_flush_fifo();
+  	//Online players were sent to save, but the ack will not arrive on time!
+	//They have to be removed from memory, and assume the char-server saved them.
+	pc_db->foreach(pc_db,cleanup_db_subpc);
 
 
 	do_final_atcommand();
 	do_final_atcommand();
 	do_final_battle();
 	do_final_battle();