From 036bbfd9ae5a4a77031fb33a87264e58214c2ba0 Mon Sep 17 00:00:00 2001 From: skotlex Date: Tue, 27 Jun 2006 14:54:01 +0000 Subject: - Fixed indentation on int_pet.c (how did it got messed up?) - Added mapflag "loadevent", now load-map script events will ONLY trigger on maps with this mapflag on, rather than every map. - High Jump can now be used in all versus maps. - Added Kaite's opt3 value, taken from jA - Added state dirty == 2 to storages. Signals when a storage was sent for final saving. Said storage is removed from memory after the ack from the char-server, and they are sent to save if the map/char servers reconnect before the act arrives. In short: they are guaranteed to be saved after a char logs out. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7358 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/storage.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'src/map/storage.c') diff --git a/src/map/storage.c b/src/map/storage.c index c420795a1..211bdb9ec 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -82,7 +82,7 @@ static int storage_reconnect_sub(DBKey key,void *data,va_list ap) { //Account Storage struct storage* stor = (struct storage*) data; if (stor->dirty && stor->storage_status == 0) //Save closed storages. - storage_storage_save(stor->account_id); + storage_storage_save(stor->account_id, stor->dirty==2?1:0); } return 0; } @@ -390,16 +390,27 @@ void storage_storage_dirty(struct map_session_data *sd) stor->dirty = 1; } -int storage_storage_save(int account_id) +int storage_storage_save(int account_id, int final) { struct storage *stor; stor=account2storage2(account_id); - if(stor && stor->dirty) + if(!stor) return 0; + + if(stor->dirty) { + if (final) { + stor->dirty = 2; + stor->storage_status = 0; //To prevent further manipulation of it. + } intif_send_storage(stor); return 1; } + if (final) + { //Clear storage from memory. Nothing to save. + storage_delete(account_id); + return 1; + } return 0; } @@ -409,13 +420,19 @@ int storage_storage_saved(int account_id) { struct storage *stor; - if((stor=account2storage2(account_id)) != NULL) + if((stor=account2storage2(account_id)) == NULL) + return 0; + + if (stor->dirty == 2) + { //Final save of storage. Remove from memory. + storage_delete(account_id); + return 1; + } + + if (stor->dirty && stor->storage_status == 0) { //Only mark it clean if it's not in use. [Skotlex] - if (stor->dirty && stor->storage_status == 0) - { - stor->dirty = 0; - sortage_sortitem(stor); - } + stor->dirty = 0; + sortage_sortitem(stor); return 1; } return 0; -- cgit v1.2.3-70-g09d2