summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/chrif.c4
-rw-r--r--src/map/intif.c2
-rw-r--r--src/map/map.c1
-rw-r--r--src/map/map.h1
-rw-r--r--src/map/storage.c60
-rw-r--r--src/map/storage.h6
6 files changed, 52 insertions, 22 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 8760e35..cc9437a 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -113,9 +113,9 @@ int chrif_save(struct map_session_data *sd)
//For data sync
if (sd->state.storage_flag == 1)
- storage_storage_save(sd->status.account_id);
+ storage_storage_save(sd->status.account_id, 0);
else if (sd->state.storage_flag == 2)
- storage_guild_storagesave(sd->status.account_id, sd->status.guild_id);
+ storage_guild_storagesave(sd->status.account_id, sd->status.guild_id, 0);
return 0;
}
diff --git a/src/map/intif.c b/src/map/intif.c
index 7f3eafc..228af46 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -676,7 +676,7 @@ int intif_parse_SaveGuildStorage(int fd)
if(battle_config.save_log) {
printf("intif_save_guild_storage: done %d %d %d\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOB(fd,10) );
}
- storage_guild_storagesaved(RFIFOL(fd,2), RFIFOL(fd,6));
+ storage_guild_storagesaved(/*RFIFOL(fd,2), */RFIFOL(fd,6));
return 0;
}
diff --git a/src/map/map.c b/src/map/map.c
index 5cc742d..ee42d3d 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -64,6 +64,7 @@ int map_num = 0;
int map_port=0;
int autosave_interval = DEFAULT_AUTOSAVE_INTERVAL;
+int save_settings = 0xFFFF;
int agit_flag = 0;
int night_flag = 0; // 0=day, 1=night [Yor]
diff --git a/src/map/map.h b/src/map/map.h
index 3ebb81c..7275734 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -638,6 +638,7 @@ struct chat_data {
extern struct map_data map[];
extern int map_num;
extern int autosave_interval;
+extern int save_settings;
extern int agit_flag;
extern int night_flag; // 0=day, 1=night [Yor]
diff --git a/src/map/storage.c b/src/map/storage.c
index 09dc17b..7a7c893 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -92,13 +92,13 @@ static int storage_reconnect_sub(void *key,void *data,va_list ap)
{ //Guild Storage
struct guild_storage* stor = (struct guild_storage*) data;
if (stor->dirty && stor->storage_status == 0) //Save closed storages.
- storage_guild_storagesave(0, stor->guild_id);
+ storage_guild_storagesave(0, stor->guild_id,0);
}
else
{ //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;
}
@@ -359,8 +359,12 @@ int storage_storageclose(struct map_session_data *sd)
clif_storageclose(sd);
if (stor->storage_status)
- chrif_save(sd); //This will invoke the storage save function as well. [Skotlex]
-
+ {
+ if (save_settings&4)
+ chrif_save(sd); //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;
@@ -396,16 +400,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;
}
@@ -651,19 +666,22 @@ int storage_guild_storagegettocart(struct map_session_data *sd,int index,int amo
return 1;
}
-int storage_guild_storagesave(int account_id, int guild_id)
+int storage_guild_storagesave(int account_id, int guild_id, int flag)
{
struct guild_storage *stor = guild2storage2(guild_id);
- if(stor && stor->dirty)
+ if(stor)
{
- intif_send_guild_storage(account_id,stor);
+ if (flag) //Char quitting, close it.
+ stor->storage_status = 0;
+ if (stor->dirty)
+ intif_send_guild_storage(account_id,stor);
return 1;
}
return 0;
}
-int storage_guild_storagesaved(int account_id, int guild_id)
+int storage_guild_storagesaved(int guild_id)
{
struct guild_storage *stor;
@@ -701,14 +719,24 @@ 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);
+ return 0;
+ }
+
+ if(stor->storage_status) {
+ if (save_settings&4)
+ chrif_save(sd);
+ else
+ storage_guild_storagesave(sd->status.account_id,sd->status.guild_id,1);
+ }
sd->state.storage_flag = 0;
stor->storage_status = 0;
- chrif_save(sd);
- 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;
}
diff --git a/src/map/storage.h b/src/map/storage.h
index 67966cf..cc93f86 100644
--- a/src/map/storage.h
+++ b/src/map/storage.h
@@ -19,7 +19,7 @@ struct storage *account2storage(int account_id);
struct storage *account2storage2(int account_id);
int storage_delete(int account_id);
int storage_storage_quit(struct map_session_data *sd);
-int storage_storage_save(int account_id);
+int storage_storage_save(int account_id, int final);
int storage_storage_saved(int account_id); //Ack from char server that guild store was saved.
void storage_storage_dirty(struct map_session_data *sd);
@@ -34,8 +34,8 @@ int storage_guild_storageaddfromcart(struct map_session_data *sd,int index,int a
int storage_guild_storagegettocart(struct map_session_data *sd,int index,int amount);
int storage_guild_storageclose(struct map_session_data *sd);
int storage_guild_storage_quit(struct map_session_data *sd,int flag);
-int storage_guild_storagesave(int account_id, int guild_id);
-int storage_guild_storagesaved(int account_id, int guild_id); //Ack from char server that guild store was saved.
+int storage_guild_storagesave(int account_id, int guild_id, int flag);
+int storage_guild_storagesaved(int guild_id); //Ack from char server that guild store was saved.
int storage_comp_item(const void *_i1, const void *_i2);
//int storage_comp_item(const struct item* i1, const struct item* i2);