From e07b2da8d90f955dbe01737e9bfdb73ddaa3bd83 Mon Sep 17 00:00:00 2001 From: skotlex Date: Wed, 28 Jun 2006 16:09:13 +0000 Subject: - Cleaned up a bit the code for @item - Fixed character/storage being sent to be saved TWICE when you logged out while the storage is opened. - Added save_settings map config. Specifies after which events do characters get saved (defaults to all): 1 - Trade successful, 2 - Vending transaction, 4 - Closing storage/guild storage, 8 - hatching a pet. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7375 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/storage.c | 56 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 17 deletions(-) (limited to 'src/map/storage.c') diff --git a/src/map/storage.c b/src/map/storage.c index 211bdb9ec..0be5d756d 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -353,8 +353,12 @@ int storage_storageclose(struct map_session_data *sd) clif_storageclose(sd); if (stor->storage_status) - chrif_save(sd,0); //This will invoke the storage save function as well. [Skotlex] - + { + if (save_settings&4) + chrif_save(sd,0); //Invokes the storage saving as well. + else + storage_storage_save(sd->status.account_id, 0); + } stor->storage_status=0; sd->state.storage_flag=0; return 0; @@ -369,14 +373,17 @@ int storage_storage_quit(struct map_session_data *sd, int flag) struct storage *stor; nullpo_retr(0, sd); - - stor = account2storage2(sd->status.account_id); - if(stor) { - chrif_save(sd, flag); //Invokes the storage saving as well. - stor->storage_status = 0; - sd->state.storage_flag = 0; + nullpo_retr(0, stor=account2storage2(sd->status.account_id)); + + if (stor->storage_status) + { + if (save_settings&4) + chrif_save(sd, flag); //Invokes the storage saving as well. + else + storage_storage_save(sd->status.account_id, flag); } - + stor->storage_status = 0; + sd->state.storage_flag = 0; return 0; } @@ -702,8 +709,13 @@ int storage_guild_storageclose(struct map_session_data *sd) nullpo_retr(0, stor=guild2storage2(sd->status.guild_id)); clif_storageclose(sd); - chrif_save(sd, 0); //This one also saves the storage. [Skotlex] - + if (stor->storage_status) + { + if (save_settings&4) + chrif_save(sd, 0); //This one also saves the storage. [Skotlex] + else + storage_guild_storagesave(sd->status.account_id, sd->status.guild_id); + } stor->storage_status=0; sd->state.storage_flag = 0; @@ -716,15 +728,25 @@ int storage_guild_storage_quit(struct map_session_data *sd,int flag) nullpo_retr(0, sd); nullpo_retr(0, stor=guild2storage2(sd->status.guild_id)); + + if(flag) + { //Only during a guild break flag is 1 (don't save storage) + sd->state.storage_flag = 0; + stor->storage_status = 0; + clif_storageclose(sd); + if (save_settings&4) + chrif_save(sd,0); + return 0; + } + if(stor->storage_status) { + if (save_settings&4) + chrif_save(sd,0); + else + storage_guild_storagesave(sd->status.account_id,sd->status.guild_id); + } sd->state.storage_flag = 0; stor->storage_status = 0; - chrif_save(sd,flag); - if(!flag) //Only during a guild break flag is 1. - storage_guild_storagesave(sd->status.account_id,sd->status.guild_id); - else //When the guild was broken, close the storage of he who has it open. - clif_storageclose(sd); - return 0; } -- cgit v1.2.3-70-g09d2