diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/mmo.h | 1 | ||||
-rw-r--r-- | src/map/intif.c | 1 | ||||
-rw-r--r-- | src/map/storage.c | 45 | ||||
-rw-r--r-- | src/map/storage.h | 1 |
4 files changed, 21 insertions, 27 deletions
diff --git a/src/common/mmo.h b/src/common/mmo.h index 378f324a1..5ee6bf602 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -152,6 +152,7 @@ struct mmo_charstatus { }; struct storage { + int dirty; int account_id; short storage_status; short storage_amount; diff --git a/src/map/intif.c b/src/map/intif.c index 66428d13d..cf9d8ccee 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -731,6 +731,7 @@ int intif_parse_LoadStorage(int fd) { if(battle_config.save_log) printf("intif_openstorage: %d\n",RFIFOL(fd,4) ); memcpy(stor,RFIFOP(fd,8),sizeof(struct storage)); + stor->dirty=0; stor->storage_status=1; sd->state.storage_flag = 0; clif_storageitemlist(sd,stor); diff --git a/src/map/storage.c b/src/map/storage.c index fc6f63cdd..fcc70845d 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -121,25 +121,6 @@ int storage_storageopen(struct map_session_data *sd) return 1; } -int storage_storageopen2(struct map_session_data *sd, struct map_session_data *pl_sd) -{ - struct storage *stor; - if(sd == NULL || pl_sd == NULL) - { - printf("storage_storageopen nullpo\n"); - return 0; - } - - if((stor = numdb_search(storage_db,pl_sd->status.account_id)) != NULL) - { - clif_storageitemlist(sd,stor); - clif_storageequiplist(sd,stor); - clif_updatestorageamount(sd,stor); - return 1; - } - return 0; -} - /*========================================== * カプラ倉庫へアイテム追加 *------------------------------------------ @@ -187,6 +168,8 @@ int storage_additem(struct map_session_data *sd,struct storage *stor,struct item if(i>=MAX_STORAGE) return 1; } + + stor->dirty = 1; return 0; } /*========================================== @@ -209,6 +192,8 @@ int storage_delitem(struct map_session_data *sd,struct storage *stor,int n,int a } clif_storageitemremoved(sd,n,amount); + stor->dirty = 1; + return 0; } /*========================================== @@ -220,7 +205,7 @@ int storage_storageadd(struct map_session_data *sd,int index,int amount) struct storage *stor; nullpo_retr(0, sd); - nullpo_retr(0, stor=account2storage(sd->status.account_id)); + nullpo_retr(0, stor=account2storage2(sd->status.account_id)); if( (stor->storage_amount <= MAX_STORAGE) && (stor->storage_status == 1) ) { // storage not full & storage open if(index>=0 && index<MAX_INVENTORY) { // valid index @@ -245,7 +230,7 @@ int storage_storageget(struct map_session_data *sd,int index,int amount) int flag; nullpo_retr(0, sd); - nullpo_retr(0, stor=account2storage(sd->status.account_id)); + nullpo_retr(0, stor=account2storage2(sd->status.account_id)); if(stor->storage_status == 1) { // storage open if(index>=0 && index<MAX_STORAGE) { // valid index @@ -269,7 +254,7 @@ int storage_storageaddfromcart(struct map_session_data *sd,int index,int amount) struct storage *stor; nullpo_retr(0, sd); - nullpo_retr(0, stor=account2storage(sd->status.account_id)); + nullpo_retr(0, stor=account2storage2(sd->status.account_id)); if( (stor->storage_amount <= MAX_STORAGE) && (stor->storage_status == 1) ) { // storage not full & storage open if(index>=0 && index<MAX_INVENTORY) { // valid index @@ -292,7 +277,7 @@ int storage_storagegettocart(struct map_session_data *sd,int index,int amount) struct storage *stor; nullpo_retr(0, sd); - nullpo_retr(0, stor=account2storage(sd->status.account_id)); + nullpo_retr(0, stor=account2storage2(sd->status.account_id)); if(stor->storage_status == 1) { // storage open if(index>=0 && index<MAX_STORAGE) { // valid index @@ -317,12 +302,14 @@ int storage_storageclose(struct map_session_data *sd) struct storage *stor; nullpo_retr(0, sd); - nullpo_retr(0, stor=account2storage(sd->status.account_id)); + nullpo_retr(0, stor=account2storage2(sd->status.account_id)); stor->storage_status=0; sd->state.storage_flag = 0; clif_storageclose(sd); + storage_storage_save(sd); + sortage_sortitem(stor); return 0; } @@ -338,7 +325,10 @@ int storage_storage_quit(struct map_session_data *sd) nullpo_retr(0, sd); stor = numdb_search(storage_db,sd->status.account_id); - if(stor) stor->storage_status = 0; + if(stor) { + stor->storage_status = 0; + storage_storage_save(sd); + } return 0; } @@ -350,7 +340,10 @@ int storage_storage_save(struct map_session_data *sd) nullpo_retr(0, sd); stor=numdb_search(storage_db,sd->status.account_id); - if(stor) intif_send_storage(stor); + if(stor && stor->dirty) { + intif_send_storage(stor); + stor->dirty = 0; + } return 0; } diff --git a/src/map/storage.h b/src/map/storage.h index 352dee4f0..489741c71 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -5,7 +5,6 @@ #include "mmo.h" int storage_storageopen(struct map_session_data *sd); -int storage_storageopen2(struct map_session_data *sd,struct map_session_data *pl_sd); int storage_storageadd(struct map_session_data *sd,int index,int amount); int storage_storageget(struct map_session_data *sd,int index,int amount); int storage_storageaddfromcart(struct map_session_data *sd,int index,int amount); |