diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-07-07 16:28:41 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-07-07 16:28:41 +0000 |
commit | 959387743887e9a57cf31b950f23be9bd34b919f (patch) | |
tree | 8a472ad961a9d3df5dea73f84ae597735b02e52e /src/map/chrif.c | |
parent | ae287ef89682be736bf1281d758e5cd3bad56895 (diff) | |
download | hercules-959387743887e9a57cf31b950f23be9bd34b919f.tar.gz hercules-959387743887e9a57cf31b950f23be9bd34b919f.tar.bz2 hercules-959387743887e9a57cf31b950f23be9bd34b919f.tar.xz hercules-959387743887e9a57cf31b950f23be9bd34b919f.zip |
- Okay, added a chrif_save_ack packet to the char-server so now the map server will know once a character was "final saved", and only then the character will be removed from memory. On char-server reconnection, all chars that are in final-save state are resent to save (if they are still in memory, it's because the ack hasn't gotten here from the char-server). This should effectively block all dupe problems due to heavy inter-server lag, however as it's untested, it currently prints some debug messages when people are saved and then removed from memory. Need testers so this can be debugged and merged to stable!
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7568 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/chrif.c')
-rw-r--r-- | src/map/chrif.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c index 211dcb6f4..0e11c6741 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -37,7 +37,7 @@ static const int packet_len_table[0x3d] = { 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,-1,-1, // 2b20-2b27: U->2b20, F->2b21, F->2b22, F->2b23, F->2b24, F->2b25, F->2b26, F->2b27
+ -1,10,-1,-1,-1,-1,-1,-1, // 2b20-2b27: U->2b20, U->2b21, F->2b22, F->2b23, F->2b24, F->2b25, F->2b26, F->2b27
};
//Used Packets:
@@ -82,7 +82,8 @@ static const int packet_len_table[0x3d] = { //2b1e: Incoming, chrif_update_ip -> 'Reqest forwarded from char-server for interserver IP sync.' [Lance]
//2b1f: Incomming, chrif_disconnectplayer -> 'disconnects a player (aid X) with the message XY ... 0x81 ..' [Sirius]
//2b20: Incomming, chrif_removemap -> 'remove maps of a server (sample: its going offline)' [Sirius]
-//2b21-2b27: FREE
+//2b21: Incomming, chrif_save_ack. Returned after a character has been "final saved" on the char-server. [Skotlex]
+//2b22-2b27: FREE
int chrif_connected;
int char_fd = 0; //Using 0 instead of -1 is safer against crashes. [Skotlex]
@@ -183,8 +184,13 @@ int chrif_isconnect(void) int chrif_save(struct map_session_data *sd, int flag)
{
nullpo_retr(-1, sd);
- chrif_check(-1);
+
pc_makesavestatus(sd);
+ if(!chrif_isconnect())
+ {
+ if (flag) sd->state.finalsave = 1; //Will save character on reconnect.
+ return -1;
+ }
if (sd->state.finalsave)
return -1; //Refuse to save a char already tagged for final saving. [Skotlex]
@@ -193,6 +199,7 @@ int chrif_save(struct map_session_data *sd, int flag) storage_storage_save(sd->status.account_id, flag);
else if (sd->state.storage_flag == 2)
storage_guild_storagesave(sd->status.account_id, sd->status.guild_id, flag);
+ if (flag) sd->state.storage_flag = 0; //Force close it.
//Saving of registry values.
if (sd->state.reg_dirty&4)
@@ -306,6 +313,14 @@ int chrif_removemap(int fd){ return 0;
}
+int chrif_save_ack(int fd) {
+ int aid = RFIFOL(fd,2), cid = RFIFOL(fd,6);
+ struct map_session_data *sd = map_id2sd(aid);
+ if (sd && sd->status.char_id == cid)
+ map_quit_ack(sd);
+ return 0;
+}
+
/*==========================================
* マップ鯖間移動のためのデータ準備要求
*------------------------------------------
@@ -416,6 +431,7 @@ int chrif_sendmapack(int fd) send_users_tochar(-1, gettick(), 0, 0);
//Re-save any storages that were modified in the disconnection time. [Skotlex]
+ do_reconnect_map();
do_reconnect_storage();
return 0;
@@ -1493,7 +1509,8 @@ int chrif_parse(int fd) case 0x2b1d: chrif_load_scdata(fd); break;
case 0x2b1e: chrif_update_ip(fd); break;
case 0x2b1f: chrif_disconnectplayer(fd); break;
- case 0x2b20: chrif_removemap(fd); break; //Remove maps of a server [Sirius]
+ case 0x2b20: chrif_removemap(fd); break;
+ case 0x2b21: chrif_save_ack(fd); break;
default:
if (battle_config.error_log)
|