summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/char/char.c4
-rw-r--r--src/char/int_storage.c197
-rw-r--r--src/char/int_storage.h3
-rw-r--r--src/common/malloc.h10
-rw-r--r--src/common/mmo.h6
-rw-r--r--src/map/atcommand.c17
-rw-r--r--src/map/chrif.c8
-rw-r--r--src/map/clif.c196
-rw-r--r--src/map/itemdb.c1
-rw-r--r--src/map/map.c28
-rw-r--r--src/map/map.h3
-rw-r--r--src/map/pc.c13
-rw-r--r--src/map/storage.c362
-rw-r--r--src/map/storage.h7
14 files changed, 507 insertions, 348 deletions
diff --git a/src/char/char.c b/src/char/char.c
index b14f25c..3035ce1 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -1792,7 +1792,7 @@ int parse_tologin(int fd) {
mapif_sendall(buf, 10); // forward package to map servers
for (i = 0; i < char_num; i++) {
struct mmo_charstatus *c = char_dat + i;
- struct storage *s = account2maybe_storage(c->account_id);
+ struct storage *s = account2storage(c->account_id);
int changes = 0;
int j;
#define FIX(v) if (v == source_id) {v = dest_id; ++changes; }
@@ -1808,7 +1808,7 @@ int parse_tologin(int fd) {
if (s)
for (j = 0; j < s->storage_amount; j++)
- FIX(s->storage[j].nameid);
+ FIX(s->storage_[j].nameid);
#undef FIX
if (changes)
char_log("itemfrob(%d -> %d): `%s'(%d, account %d): changed %d times\n", source_id, dest_id,
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index 0774370..e8cbd26 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -1,16 +1,18 @@
// $Id: int_storage.c,v 1.1.1.1 2004/09/10 17:26:51 MagicalTux Exp $
-#include "inter.h"
-#include "int_storage.h"
-#include "int_guild.h"
-#include "mmo.h"
-#include "char.h"
-#include "socket.h"
-#include "db.h"
-#include "lock.h"
#include <string.h>
#include <stdlib.h>
+#include "../common/mmo.h"
+#include "../common/socket.h"
+#include "../common/db.h"
+#include "../common/lock.h"
+#include "../common/malloc.h"
+#include "char.h"
+#include "inter.h"
+#include "int_storage.h"
+#include "int_guild.h"
+
// ファイル名のデフォルト
// inter_config_read()で再設定される
char storage_txt[1024]="save/storage.txt";
@@ -27,11 +29,11 @@ int storage_tostr(char *str,struct storage *p)
str_p += sprintf(str_p,"%d,%d\t",p->account_id,p->storage_amount);
for(i=0;i<MAX_STORAGE;i++)
- if( (p->storage[i].nameid) && (p->storage[i].amount) ){
- str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ",
- p->storage[i].id,p->storage[i].nameid,p->storage[i].amount,p->storage[i].equip,
- p->storage[i].identify,p->storage[i].refine,p->storage[i].attribute,
- p->storage[i].card[0],p->storage[i].card[1],p->storage[i].card[2],p->storage[i].card[3],p->storage[i].broken);
+ if( (p->storage_[i].nameid) && (p->storage_[i].amount) ){
+ str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ",
+ p->storage_[i].id,p->storage_[i].nameid,p->storage_[i].amount,p->storage_[i].equip,
+ p->storage_[i].identify,p->storage_[i].refine,p->storage_[i].attribute,
+ p->storage_[i].card[0],p->storage_[i].card[1],p->storage_[i].card[2],p->storage_[i].card[3]);
f++;
}
@@ -55,51 +57,49 @@ int storage_fromstr(char *str,struct storage *p)
if(set!=2)
return 1;
if(str[next]=='\n' || str[next]=='\r')
- return 0;
+ return 0;
next++;
for(i=0;str[next] && str[next]!='\t';i++){
if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
&tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
&tmp_int[4], &tmp_int[5], &tmp_int[6],
- &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[11], &len) == 12) {
- p->storage[i].id = tmp_int[0];
- p->storage[i].nameid = tmp_int[1];
- p->storage[i].amount = tmp_int[2];
- p->storage[i].equip = tmp_int[3];
- p->storage[i].identify = tmp_int[4];
- p->storage[i].refine = tmp_int[5];
- p->storage[i].attribute = tmp_int[6];
- p->storage[i].card[0] = tmp_int[7];
- p->storage[i].card[1] = tmp_int[8];
- p->storage[i].card[2] = tmp_int[9];
- p->storage[i].card[3] = tmp_int[10];
- p->storage[i].broken = tmp_int[11];
+ &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[10], &len) == 12) {
+ p->storage_[i].id = tmp_int[0];
+ p->storage_[i].nameid = tmp_int[1];
+ p->storage_[i].amount = tmp_int[2];
+ p->storage_[i].equip = tmp_int[3];
+ p->storage_[i].identify = tmp_int[4];
+ p->storage_[i].refine = tmp_int[5];
+ p->storage_[i].attribute = tmp_int[6];
+ p->storage_[i].card[0] = tmp_int[7];
+ p->storage_[i].card[1] = tmp_int[8];
+ p->storage_[i].card[2] = tmp_int[9];
+ p->storage_[i].card[3] = tmp_int[10];
next += len;
if (str[next] == ' ')
- next++;
+ next++;
}
else if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
&tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
&tmp_int[4], &tmp_int[5], &tmp_int[6],
&tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &len) == 11) {
- p->storage[i].id = tmp_int[0];
- p->storage[i].nameid = tmp_int[1];
- p->storage[i].amount = tmp_int[2];
- p->storage[i].equip = tmp_int[3];
- p->storage[i].identify = tmp_int[4];
- p->storage[i].refine = tmp_int[5];
- p->storage[i].attribute = tmp_int[6];
- p->storage[i].card[0] = tmp_int[7];
- p->storage[i].card[1] = tmp_int[8];
- p->storage[i].card[2] = tmp_int[9];
- p->storage[i].card[3] = tmp_int[10];
- p->storage[i].broken = 0;
+ p->storage_[i].id = tmp_int[0];
+ p->storage_[i].nameid = tmp_int[1];
+ p->storage_[i].amount = tmp_int[2];
+ p->storage_[i].equip = tmp_int[3];
+ p->storage_[i].identify = tmp_int[4];
+ p->storage_[i].refine = tmp_int[5];
+ p->storage_[i].attribute = tmp_int[6];
+ p->storage_[i].card[0] = tmp_int[7];
+ p->storage_[i].card[1] = tmp_int[8];
+ p->storage_[i].card[2] = tmp_int[9];
+ p->storage_[i].card[3] = tmp_int[10];
next += len;
if (str[next] == ' ')
- next++;
+ next++;
}
-
+
else return 1;
}
return 0;
@@ -112,11 +112,11 @@ int guild_storage_tostr(char *str,struct guild_storage *p)
str_p+=sprintf(str,"%d,%d\t",p->guild_id,p->storage_amount);
for(i=0;i<MAX_GUILD_STORAGE;i++)
- if( (p->storage[i].nameid) && (p->storage[i].amount) ){
- str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ",
- p->storage[i].id,p->storage[i].nameid,p->storage[i].amount,p->storage[i].equip,
- p->storage[i].identify,p->storage[i].refine,p->storage[i].attribute,
- p->storage[i].card[0],p->storage[i].card[1],p->storage[i].card[2],p->storage[i].card[3],p->storage[i].broken);
+ if( (p->storage_[i].nameid) && (p->storage_[i].amount) ){
+ str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ",
+ p->storage_[i].id,p->storage_[i].nameid,p->storage_[i].amount,p->storage_[i].equip,
+ p->storage_[i].identify,p->storage_[i].refine,p->storage_[i].attribute,
+ p->storage_[i].card[0],p->storage_[i].card[1],p->storage_[i].card[2],p->storage_[i].card[3]);
f++;
}
@@ -139,70 +139,61 @@ int guild_storage_fromstr(char *str,struct guild_storage *p)
if(set!=2)
return 1;
if(str[next]=='\n' || str[next]=='\r')
- return 0;
+ return 0;
next++;
for(i=0;str[next] && str[next]!='\t';i++){
if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
&tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
&tmp_int[4], &tmp_int[5], &tmp_int[6],
- &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[11], &len) == 12) {
- p->storage[i].id = tmp_int[0];
- p->storage[i].nameid = tmp_int[1];
- p->storage[i].amount = tmp_int[2];
- p->storage[i].equip = tmp_int[3];
- p->storage[i].identify = tmp_int[4];
- p->storage[i].refine = tmp_int[5];
- p->storage[i].attribute = tmp_int[6];
- p->storage[i].card[0] = tmp_int[7];
- p->storage[i].card[1] = tmp_int[8];
- p->storage[i].card[2] = tmp_int[9];
- p->storage[i].card[3] = tmp_int[10];
- p->storage[i].broken = tmp_int[11];
+ &tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[10], &len) == 12) {
+ p->storage_[i].id = tmp_int[0];
+ p->storage_[i].nameid = tmp_int[1];
+ p->storage_[i].amount = tmp_int[2];
+ p->storage_[i].equip = tmp_int[3];
+ p->storage_[i].identify = tmp_int[4];
+ p->storage_[i].refine = tmp_int[5];
+ p->storage_[i].attribute = tmp_int[6];
+ p->storage_[i].card[0] = tmp_int[7];
+ p->storage_[i].card[1] = tmp_int[8];
+ p->storage_[i].card[2] = tmp_int[9];
+ p->storage_[i].card[3] = tmp_int[10];
next += len;
if (str[next] == ' ')
- next++;
+ next++;
}
else if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
&tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
&tmp_int[4], &tmp_int[5], &tmp_int[6],
&tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &len) == 11) {
- p->storage[i].id = tmp_int[0];
- p->storage[i].nameid = tmp_int[1];
- p->storage[i].amount = tmp_int[2];
- p->storage[i].equip = tmp_int[3];
- p->storage[i].identify = tmp_int[4];
- p->storage[i].refine = tmp_int[5];
- p->storage[i].attribute = tmp_int[6];
- p->storage[i].card[0] = tmp_int[7];
- p->storage[i].card[1] = tmp_int[8];
- p->storage[i].card[2] = tmp_int[9];
- p->storage[i].card[3] = tmp_int[10];
- p->storage[i].broken = 0;
+ p->storage_[i].id = tmp_int[0];
+ p->storage_[i].nameid = tmp_int[1];
+ p->storage_[i].amount = tmp_int[2];
+ p->storage_[i].equip = tmp_int[3];
+ p->storage_[i].identify = tmp_int[4];
+ p->storage_[i].refine = tmp_int[5];
+ p->storage_[i].attribute = tmp_int[6];
+ p->storage_[i].card[0] = tmp_int[7];
+ p->storage_[i].card[1] = tmp_int[8];
+ p->storage_[i].card[2] = tmp_int[9];
+ p->storage_[i].card[3] = tmp_int[10];
next += len;
if (str[next] == ' ')
- next++;
+ next++;
}
-
+
else return 1;
}
return 0;
}
// アカウントから倉庫データインデックスを得る(新規倉庫追加可能)
-struct storage *account2maybe_storage(int account_id)
-{
- struct storage *s;
- s=numdb_search(storage_db,account_id);
- return s;
-}
-
struct storage *account2storage(int account_id)
{
- struct storage *s = account2maybe_storage(account_id);
-
+ struct storage *s;
+ s= (struct storage *) numdb_search(storage_db,account_id);
if(s == NULL) {
- s = calloc(sizeof(struct storage), 1);
+ s = (struct storage *) aCalloc(sizeof(struct storage), 1);
if(s==NULL){
printf("int_storage: out of memory!\n");
exit(0);
@@ -218,14 +209,14 @@ struct guild_storage *guild2storage(int guild_id)
{
struct guild_storage *gs = NULL;
if(inter_guild_search(guild_id) != NULL) {
- gs=numdb_search(guild_storage_db,guild_id);
+ gs= (struct guild_storage *) numdb_search(guild_storage_db,guild_id);
if(gs == NULL) {
- gs = calloc(sizeof(struct guild_storage), 1);
+ gs = (struct guild_storage *) aCalloc(sizeof(struct guild_storage), 1);
if(gs==NULL){
printf("int_storage: out of memory!\n");
exit(0);
}
- memset(gs,0,sizeof(struct guild_storage));
+// memset(gs,0,sizeof(struct guild_storage)); aCalloc does this! [Skotlex]
gs->guild_id=guild_id;
numdb_insert(guild_storage_db,gs->guild_id,gs);
}
@@ -252,12 +243,12 @@ int inter_storage_init()
}
while(fgets(line,65535,fp)){
sscanf(line,"%d",&tmp_int);
- s=calloc(sizeof(struct storage), 1);
+ s = (struct storage*)aCalloc(sizeof(struct storage), 1);
if(s==NULL){
printf("int_storage: out of memory!\n");
exit(0);
}
- memset(s,0,sizeof(struct storage));
+// memset(s,0,sizeof(struct storage)); aCalloc does this...
s->account_id=tmp_int;
if(s->account_id > 0 && storage_fromstr(line,s) == 0) {
numdb_insert(storage_db,s->account_id,s);
@@ -280,12 +271,12 @@ int inter_storage_init()
}
while(fgets(line,65535,fp)){
sscanf(line,"%d",&tmp_int);
- gs=calloc(sizeof(struct guild_storage), 1);
+ gs = (struct guild_storage*)aCalloc(sizeof(struct guild_storage), 1);
if(gs==NULL){
printf("int_storage: out of memory!\n");
exit(0);
}
- memset(gs,0,sizeof(struct guild_storage));
+// memset(gs,0,sizeof(struct guild_storage)); aCalloc...
gs->guild_id=tmp_int;
if(gs->guild_id > 0 && guild_storage_fromstr(line,gs) == 0) {
numdb_insert(guild_storage_db,gs->guild_id,gs);
@@ -301,6 +292,22 @@ int inter_storage_init()
return 0;
}
+int storage_db_final (void *k, void *data, va_list ap) {
+ struct storage *p = (struct storage *) data;
+ if (p) free(p);
+ return 0;
+}
+int guild_storage_db_final (void *k, void *data, va_list ap) {
+ struct guild_storage *p = (struct guild_storage *) data;
+ if (p) free(p);
+ return 0;
+}
+void inter_storage_final() {
+ numdb_final(storage_db, storage_db_final);
+ numdb_final(guild_storage_db, guild_storage_db_final);
+ return;
+}
+
int inter_storage_save_sub(void *key,void *data,va_list ap)
{
char line[65536];
@@ -358,7 +365,7 @@ int inter_guild_storage_save()
// 倉庫データ削除
int inter_storage_delete(int account_id)
{
- struct storage *s = numdb_search(storage_db,account_id);
+ struct storage *s = (struct storage *) numdb_search(storage_db,account_id);
if(s) {
numdb_erase(storage_db,account_id);
free(s);
@@ -369,7 +376,7 @@ int inter_storage_delete(int account_id)
// ギルド倉庫データ削除
int inter_guild_storage_delete(int guild_id)
{
- struct guild_storage *gs = numdb_search(guild_storage_db,guild_id);
+ struct guild_storage *gs = (struct guild_storage *) numdb_search(guild_storage_db,guild_id);
if(gs) {
numdb_erase(guild_storage_db,guild_id);
free(gs);
diff --git a/src/char/int_storage.h b/src/char/int_storage.h
index 59f56c6..ec23813 100644
--- a/src/char/int_storage.h
+++ b/src/char/int_storage.h
@@ -3,11 +3,12 @@
#define _INT_STORAGE_H_
int inter_storage_init();
+void inter_storage_final();
int inter_storage_save();
int inter_guild_storage_save();
int inter_storage_delete(int account_id);
int inter_guild_storage_delete(int guild_id);
-struct storage *account2maybe_storage(int account_id);
+struct storage *account2storage(int account_id);
int inter_storage_parse_frommap(int fd);
diff --git a/src/common/malloc.h b/src/common/malloc.h
index 3733a5e..da16f06 100644
--- a/src/common/malloc.h
+++ b/src/common/malloc.h
@@ -13,13 +13,17 @@
#define ALC_MARK __FILE__, __LINE__, __func__
-void* aMalloc_( size_t size, const char *file, int line, const char *func );
-void* aCalloc_( size_t num, size_t size, const char *file, int line, const char *func );
-void* aRealloc_( void *p, size_t size, const char *file, int line, const char *func );
+void* aMalloc_ (size_t, const char *, int, const char *);
+void* aCalloc_ (size_t, size_t, const char *, int, const char *);
+void* aRealloc_ (void *, size_t, const char *, int, const char *);
#define aMalloc(n) aMalloc_(n,ALC_MARK)
+#define aMallocA(n) aMalloc_(n,ALC_MARK)
#define aCalloc(m,n) aCalloc_(m,n,ALC_MARK)
+#define aCallocA(m,n) aCalloc_(m,n,ALC_MARK)
#define aRealloc(p,n) aRealloc_(p,n,ALC_MARK)
+#define aStrdup(p) aStrdup_(p,ALC_MARK)
+#define aFree(p) aFree_(p,ALC_MARK)
#endif
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 377f0b8..40904d7 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -128,17 +128,19 @@ struct mmo_charstatus {
};
struct storage {
+ int dirty;
int account_id;
short storage_status;
short storage_amount;
- struct item storage[MAX_STORAGE];
+ struct item storage_[MAX_STORAGE];
};
struct guild_storage {
+ int dirty;
int guild_id;
short storage_status;
short storage_amount;
- struct item storage[MAX_GUILD_STORAGE];
+ struct item storage_[MAX_GUILD_STORAGE];
};
struct map_session_data;
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 2283961..4696f60 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -1375,10 +1375,11 @@ int atcommand_save(
const int fd, struct map_session_data* sd,
const char* command, const char* message)
{
+ nullpo_retr(-1, sd);
+
pc_setsavepoint(sd, sd->mapname, sd->bl.x, sd->bl.y);
pc_makesavestatus(sd);
chrif_save(sd);
- storage_storage_save(sd);
clif_displaymessage(fd, msg_table[6]); // Character data respawn point saved.
return 0;
@@ -6093,23 +6094,23 @@ atcommand_character_storage_list(
counter = 0;
count = 0;
for (i = 0; i < MAX_STORAGE; i++) {
- if (stor->storage[i].nameid > 0 && (item_data = itemdb_search(stor->storage[i].nameid)) != NULL) {
- counter = counter + stor->storage[i].amount;
+ if (stor->storage_[i].nameid > 0 && (item_data = itemdb_search(stor->storage_[i].nameid)) != NULL) {
+ counter = counter + stor->storage_[i].amount;
count++;
if (count == 1) {
sprintf(output, "------ Storage items list of '%s' ------", pl_sd->status.name);
clif_displaymessage(fd, output);
}
- if (stor->storage[i].refine)
- sprintf(output, "%d %s %+d (%s %+d, id: %d)", stor->storage[i].amount, item_data->name, stor->storage[i].refine, item_data->jname, stor->storage[i].refine, stor->storage[i].nameid);
+ if (stor->storage_[i].refine)
+ sprintf(output, "%d %s %+d (%s %+d, id: %d)", stor->storage_[i].amount, item_data->name, stor->storage_[i].refine, item_data->jname, stor->storage_[i].refine, stor->storage_[i].nameid);
else
- sprintf(output, "%d %s (%s, id: %d)", stor->storage[i].amount, item_data->name, item_data->jname, stor->storage[i].nameid);
+ sprintf(output, "%d %s (%s, id: %d)", stor->storage_[i].amount, item_data->name, item_data->jname, stor->storage_[i].nameid);
clif_displaymessage(fd, output);
memset(output, '\0', sizeof(output));
counter2 = 0;
for (j = 0; j < item_data->slot; j++) {
- if (stor->storage[i].card[j]) {
- if ((item_temp = itemdb_search(stor->storage[i].card[j])) != NULL) {
+ if (stor->storage_[i].card[j]) {
+ if ((item_temp = itemdb_search(stor->storage_[i].card[j])) != NULL) {
if (output[0] == '\0')
sprintf(outputtmp, " -> (card(s): #%d %s (%s), ", ++counter2, item_temp->name, item_temp->jname);
else
diff --git a/src/map/chrif.c b/src/map/chrif.c
index b27ad88..8760e35 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -111,7 +111,11 @@ int chrif_save(struct map_session_data *sd)
memcpy(WFIFOP(char_fd,12), &sd->status, sizeof(sd->status));
WFIFOSET(char_fd, WFIFOW(char_fd,2));
- storage_storage_save(sd); // to synchronise storage with character [Yor]
+ //For data sync
+ if (sd->state.storage_flag == 1)
+ storage_storage_save(sd->status.account_id);
+ else if (sd->state.storage_flag == 2)
+ storage_guild_storagesave(sd->status.account_id, sd->status.guild_id);
return 0;
}
@@ -938,7 +942,7 @@ static int ladmin_itemfrob_c2(struct block_list *bl, int source_id, int dest_id)
if (stor)
for (j = 0; j < stor->storage_amount; j++)
- FIX(stor->storage[j]);
+ FIX(stor->storage_[j]);
for (j = 0; j < MAX_INVENTORY; j++) {
struct item_data *item = pc->inventory_data[j];
diff --git a/src/map/clif.c b/src/map/clif.c
index ec7e586..244bbd0 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -1858,9 +1858,9 @@ int clif_storageitemlist(struct map_session_data *sd,struct storage *stor)
buf = WFIFOP(fd,0);
WBUFW(buf,0)=0x1f0;
for(i=0,n=0;i<MAX_STORAGE;i++){
- if(stor->storage[i].nameid<=0)
+ if(stor->storage_[i].nameid<=0)
continue;
- nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
+ nullpo_retr(0, id = itemdb_search(stor->storage_[i].nameid));
if(itemdb_isequip2(id))
continue;
@@ -1868,15 +1868,15 @@ int clif_storageitemlist(struct map_session_data *sd,struct storage *stor)
if(id->view_id > 0)
WBUFW(buf,n*18+6)=id->view_id;
else
- WBUFW(buf,n*18+6)=stor->storage[i].nameid;
+ WBUFW(buf,n*18+6)=stor->storage_[i].nameid;
WBUFB(buf,n*18+8)=id->type;;
- WBUFB(buf,n*18+9)=stor->storage[i].identify;
- WBUFW(buf,n*18+10)=stor->storage[i].amount;
+ WBUFB(buf,n*18+9)=stor->storage_[i].identify;
+ WBUFW(buf,n*18+10)=stor->storage_[i].amount;
WBUFW(buf,n*18+12)=0;
- WBUFW(buf,n*18+14)=stor->storage[i].card[0];
- WBUFW(buf,n*18+16)=stor->storage[i].card[1];
- WBUFW(buf,n*18+18)=stor->storage[i].card[2];
- WBUFW(buf,n*18+20)=stor->storage[i].card[3];
+ WBUFW(buf,n*18+14)=stor->storage_[i].card[0];
+ WBUFW(buf,n*18+16)=stor->storage_[i].card[1];
+ WBUFW(buf,n*18+18)=stor->storage_[i].card[2];
+ WBUFW(buf,n*18+20)=stor->storage_[i].card[3];
n++;
}
if(n){
@@ -1903,47 +1903,47 @@ int clif_storageequiplist(struct map_session_data *sd,struct storage *stor)
buf = WFIFOP(fd,0);
WBUFW(buf,0)=0xa6;
for(i=0,n=0;i<MAX_STORAGE;i++){
- if(stor->storage[i].nameid<=0)
+ if(stor->storage_[i].nameid<=0)
continue;
- nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
+ nullpo_retr(0, id = itemdb_search(stor->storage_[i].nameid));
if(!itemdb_isequip2(id))
continue;
WBUFW(buf,n*20+4)=i+1;
if(id->view_id > 0)
WBUFW(buf,n*20+6)=id->view_id;
else
- WBUFW(buf,n*20+6)=stor->storage[i].nameid;
+ WBUFW(buf,n*20+6)=stor->storage_[i].nameid;
WBUFB(buf,n*20+8)=id->type;
- WBUFB(buf,n*20+9)=stor->storage[i].identify;
+ WBUFB(buf,n*20+9)=stor->storage_[i].identify;
WBUFW(buf,n*20+10)=id->equip;
- WBUFW(buf,n*20+12)=stor->storage[i].equip;
- if(stor->storage[i].broken==1)
+ WBUFW(buf,n*20+12)=stor->storage_[i].equip;
+ if(stor->storage_[i].broken==1)
WBUFB(buf,n*20+14)=1; //is weapon broken [Valaris]
else
- WBUFB(buf,n*20+14)=stor->storage[i].attribute;
- WBUFB(buf,n*20+15)=stor->storage[i].refine;
- if(stor->storage[i].card[0]==0x00ff || stor->storage[i].card[0]==0x00fe || stor->storage[i].card[0]==(short)0xff00) {
- WBUFW(buf,n*20+16)=stor->storage[i].card[0];
- WBUFW(buf,n*20+18)=stor->storage[i].card[1];
- WBUFW(buf,n*20+20)=stor->storage[i].card[2];
- WBUFW(buf,n*20+22)=stor->storage[i].card[3];
+ WBUFB(buf,n*20+14)=stor->storage_[i].attribute;
+ WBUFB(buf,n*20+15)=stor->storage_[i].refine;
+ if(stor->storage_[i].card[0]==0x00ff || stor->storage_[i].card[0]==0x00fe || stor->storage_[i].card[0]==(short)0xff00) {
+ WBUFW(buf,n*20+16)=stor->storage_[i].card[0];
+ WBUFW(buf,n*20+18)=stor->storage_[i].card[1];
+ WBUFW(buf,n*20+20)=stor->storage_[i].card[2];
+ WBUFW(buf,n*20+22)=stor->storage_[i].card[3];
} else {
- if(stor->storage[i].card[0] > 0 && (j=itemdb_viewid(stor->storage[i].card[0])) > 0)
+ if(stor->storage_[i].card[0] > 0 && (j=itemdb_viewid(stor->storage_[i].card[0])) > 0)
WBUFW(buf,n*20+16)=j;
else
- WBUFW(buf,n*20+16)=stor->storage[i].card[0];
- if(stor->storage[i].card[1] > 0 && (j=itemdb_viewid(stor->storage[i].card[1])) > 0)
+ WBUFW(buf,n*20+16)=stor->storage_[i].card[0];
+ if(stor->storage_[i].card[1] > 0 && (j=itemdb_viewid(stor->storage_[i].card[1])) > 0)
WBUFW(buf,n*20+18)=j;
else
- WBUFW(buf,n*20+18)=stor->storage[i].card[1];
- if(stor->storage[i].card[2] > 0 && (j=itemdb_viewid(stor->storage[i].card[2])) > 0)
+ WBUFW(buf,n*20+18)=stor->storage_[i].card[1];
+ if(stor->storage_[i].card[2] > 0 && (j=itemdb_viewid(stor->storage_[i].card[2])) > 0)
WBUFW(buf,n*20+20)=j;
else
- WBUFW(buf,n*20+20)=stor->storage[i].card[2];
- if(stor->storage[i].card[3] > 0 && (j=itemdb_viewid(stor->storage[i].card[3])) > 0)
+ WBUFW(buf,n*20+20)=stor->storage_[i].card[2];
+ if(stor->storage_[i].card[3] > 0 && (j=itemdb_viewid(stor->storage_[i].card[3])) > 0)
WBUFW(buf,n*20+22)=j;
else
- WBUFW(buf,n*20+22)=stor->storage[i].card[3];
+ WBUFW(buf,n*20+22)=stor->storage_[i].card[3];
}
n++;
}
@@ -1972,9 +1972,9 @@ int clif_guildstorageitemlist(struct map_session_data *sd,struct guild_storage *
WBUFW(buf,0)=0x1f0;
for(i=0,n=0;i<MAX_GUILD_STORAGE;i++){
- if(stor->storage[i].nameid<=0)
+ if(stor->storage_[i].nameid<=0)
continue;
- nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
+ nullpo_retr(0, id = itemdb_search(stor->storage_[i].nameid));
if(itemdb_isequip2(id))
continue;
@@ -1982,15 +1982,15 @@ int clif_guildstorageitemlist(struct map_session_data *sd,struct guild_storage *
if(id->view_id > 0)
WBUFW(buf,n*18+6)=id->view_id;
else
- WBUFW(buf,n*18+6)=stor->storage[i].nameid;
+ WBUFW(buf,n*18+6)=stor->storage_[i].nameid;
WBUFB(buf,n*18+8)=id->type;;
- WBUFB(buf,n*18+9)=stor->storage[i].identify;
- WBUFW(buf,n*18+10)=stor->storage[i].amount;
+ WBUFB(buf,n*18+9)=stor->storage_[i].identify;
+ WBUFW(buf,n*18+10)=stor->storage_[i].amount;
WBUFW(buf,n*18+12)=0;
- WBUFW(buf,n*18+14)=stor->storage[i].card[0];
- WBUFW(buf,n*18+16)=stor->storage[i].card[1];
- WBUFW(buf,n*18+18)=stor->storage[i].card[2];
- WBUFW(buf,n*18+20)=stor->storage[i].card[3];
+ WBUFW(buf,n*18+14)=stor->storage_[i].card[0];
+ WBUFW(buf,n*18+16)=stor->storage_[i].card[1];
+ WBUFW(buf,n*18+18)=stor->storage_[i].card[2];
+ WBUFW(buf,n*18+20)=stor->storage_[i].card[3];
n++;
}
if(n){
@@ -2017,47 +2017,47 @@ int clif_guildstorageequiplist(struct map_session_data *sd,struct guild_storage
WBUFW(buf,0)=0xa6;
for(i=0,n=0;i<MAX_GUILD_STORAGE;i++){
- if(stor->storage[i].nameid<=0)
+ if(stor->storage_[i].nameid<=0)
continue;
- nullpo_retr(0, id = itemdb_search(stor->storage[i].nameid));
+ nullpo_retr(0, id = itemdb_search(stor->storage_[i].nameid));
if(!itemdb_isequip2(id))
continue;
WBUFW(buf,n*20+4)=i+1;
if(id->view_id > 0)
WBUFW(buf,n*20+6)=id->view_id;
else
- WBUFW(buf,n*20+6)=stor->storage[i].nameid;
+ WBUFW(buf,n*20+6)=stor->storage_[i].nameid;
WBUFB(buf,n*20+8)=id->type;
- WBUFB(buf,n*20+9)=stor->storage[i].identify;
+ WBUFB(buf,n*20+9)=stor->storage_[i].identify;
WBUFW(buf,n*20+10)=id->equip;
- WBUFW(buf,n*20+12)=stor->storage[i].equip;
- if(stor->storage[i].broken==1)
+ WBUFW(buf,n*20+12)=stor->storage_[i].equip;
+ if(stor->storage_[i].broken==1)
WBUFB(buf,n*20+14)=1; // is weapon broken [Valaris]
else
- WBUFB(buf,n*20+14)=stor->storage[i].attribute;
- WBUFB(buf,n*20+15)=stor->storage[i].refine;
- if(stor->storage[i].card[0]==0x00ff || stor->storage[i].card[0]==0x00fe || stor->storage[i].card[0]==(short)0xff00) {
- WBUFW(buf,n*20+16)=stor->storage[i].card[0];
- WBUFW(buf,n*20+18)=stor->storage[i].card[1];
- WBUFW(buf,n*20+20)=stor->storage[i].card[2];
- WBUFW(buf,n*20+22)=stor->storage[i].card[3];
+ WBUFB(buf,n*20+14)=stor->storage_[i].attribute;
+ WBUFB(buf,n*20+15)=stor->storage_[i].refine;
+ if(stor->storage_[i].card[0]==0x00ff || stor->storage_[i].card[0]==0x00fe || stor->storage_[i].card[0]==(short)0xff00) {
+ WBUFW(buf,n*20+16)=stor->storage_[i].card[0];
+ WBUFW(buf,n*20+18)=stor->storage_[i].card[1];
+ WBUFW(buf,n*20+20)=stor->storage_[i].card[2];
+ WBUFW(buf,n*20+22)=stor->storage_[i].card[3];
} else {
- if(stor->storage[i].card[0] > 0 && (j=itemdb_viewid(stor->storage[i].card[0])) > 0)
+ if(stor->storage_[i].card[0] > 0 && (j=itemdb_viewid(stor->storage_[i].card[0])) > 0)
WBUFW(buf,n*20+16)=j;
else
- WBUFW(buf,n*20+16)=stor->storage[i].card[0];
- if(stor->storage[i].card[1] > 0 && (j=itemdb_viewid(stor->storage[i].card[1])) > 0)
+ WBUFW(buf,n*20+16)=stor->storage_[i].card[0];
+ if(stor->storage_[i].card[1] > 0 && (j=itemdb_viewid(stor->storage_[i].card[1])) > 0)
WBUFW(buf,n*20+18)=j;
else
- WBUFW(buf,n*20+18)=stor->storage[i].card[1];
- if(stor->storage[i].card[2] > 0 && (j=itemdb_viewid(stor->storage[i].card[2])) > 0)
+ WBUFW(buf,n*20+18)=stor->storage_[i].card[1];
+ if(stor->storage_[i].card[2] > 0 && (j=itemdb_viewid(stor->storage_[i].card[2])) > 0)
WBUFW(buf,n*20+20)=j;
else
- WBUFW(buf,n*20+20)=stor->storage[i].card[2];
- if(stor->storage[i].card[3] > 0 && (j=itemdb_viewid(stor->storage[i].card[3])) > 0)
+ WBUFW(buf,n*20+20)=stor->storage_[i].card[2];
+ if(stor->storage_[i].card[3] > 0 && (j=itemdb_viewid(stor->storage_[i].card[3])) > 0)
WBUFW(buf,n*20+22)=j;
else
- WBUFW(buf,n*20+22)=stor->storage[i].card[3];
+ WBUFW(buf,n*20+22)=stor->storage_[i].card[3];
}
n++;
}
@@ -3059,38 +3059,38 @@ int clif_storageitemadded(struct map_session_data *sd,struct storage *stor,int i
WFIFOW(fd,0) =0xf4; // Storage item added
WFIFOW(fd,2) =index+1; // index
WFIFOL(fd,4) =amount; // amount
-/* if((view = itemdb_viewid(stor->storage[index].nameid)) > 0)
+/* if((view = itemdb_viewid(stor->storage_[index].nameid)) > 0)
WFIFOW(fd,8) =view;
else*/
- WFIFOW(fd,8) =stor->storage[index].nameid;
- WFIFOB(fd,10)=stor->storage[index].identify; //identify flag
- if(stor->storage[index].broken==1)
+ WFIFOW(fd,8) =stor->storage_[index].nameid;
+ WFIFOB(fd,10)=stor->storage_[index].identify; //identify flag
+ if(stor->storage_[index].broken==1)
WFIFOB(fd,11)=1; // is weapon broken [Valaris]
else
- WFIFOB(fd,11)=stor->storage[index].attribute; // attribute
- WFIFOB(fd,12)=stor->storage[index].refine; //refine
- if(stor->storage[index].card[0]==0x00ff || stor->storage[index].card[0]==0x00fe || stor->storage[index].card[0]==(short)0xff00) {
- WFIFOW(fd,13)=stor->storage[index].card[0]; //card (4w)
- WFIFOW(fd,15)=stor->storage[index].card[1]; //card (4w)
- WFIFOW(fd,17)=stor->storage[index].card[2]; //card (4w)
- WFIFOW(fd,19)=stor->storage[index].card[3]; //card (4w)
+ WFIFOB(fd,11)=stor->storage_[index].attribute; // attribute
+ WFIFOB(fd,12)=stor->storage_[index].refine; //refine
+ if(stor->storage_[index].card[0]==0x00ff || stor->storage_[index].card[0]==0x00fe || stor->storage_[index].card[0]==(short)0xff00) {
+ WFIFOW(fd,13)=stor->storage_[index].card[0]; //card (4w)
+ WFIFOW(fd,15)=stor->storage_[index].card[1]; //card (4w)
+ WFIFOW(fd,17)=stor->storage_[index].card[2]; //card (4w)
+ WFIFOW(fd,19)=stor->storage_[index].card[3]; //card (4w)
} else {
- if(stor->storage[index].card[0] > 0 && (j=itemdb_viewid(stor->storage[index].card[0])) > 0)
+ if(stor->storage_[index].card[0] > 0 && (j=itemdb_viewid(stor->storage_[index].card[0])) > 0)
WFIFOW(fd,13)= j;
else
- WFIFOW(fd,13)= stor->storage[index].card[0];
- if(stor->storage[index].card[1] > 0 && (j=itemdb_viewid(stor->storage[index].card[1])) > 0)
+ WFIFOW(fd,13)= stor->storage_[index].card[0];
+ if(stor->storage_[index].card[1] > 0 && (j=itemdb_viewid(stor->storage_[index].card[1])) > 0)
WFIFOW(fd,15)= j;
else
- WFIFOW(fd,15)= stor->storage[index].card[1];
- if(stor->storage[index].card[2] > 0 && (j=itemdb_viewid(stor->storage[index].card[2])) > 0)
+ WFIFOW(fd,15)= stor->storage_[index].card[1];
+ if(stor->storage_[index].card[2] > 0 && (j=itemdb_viewid(stor->storage_[index].card[2])) > 0)
WFIFOW(fd,17)= j;
else
- WFIFOW(fd,17)= stor->storage[index].card[2];
- if(stor->storage[index].card[3] > 0 && (j=itemdb_viewid(stor->storage[index].card[3])) > 0)
+ WFIFOW(fd,17)= stor->storage_[index].card[2];
+ if(stor->storage_[index].card[3] > 0 && (j=itemdb_viewid(stor->storage_[index].card[3])) > 0)
WFIFOW(fd,19)= j;
else
- WFIFOW(fd,19)= stor->storage[index].card[3];
+ WFIFOW(fd,19)= stor->storage_[index].card[3];
}
WFIFOSET(fd,packet_len_table[0xf4]);
@@ -3132,38 +3132,38 @@ int clif_guildstorageitemadded(struct map_session_data *sd,struct guild_storage
WFIFOW(fd,0) =0xf4; // Storage item added
WFIFOW(fd,2) =index+1; // index
WFIFOL(fd,4) =amount; // amount
- if((view = itemdb_viewid(stor->storage[index].nameid)) > 0)
+ if((view = itemdb_viewid(stor->storage_[index].nameid)) > 0)
WFIFOW(fd,8) =view;
else
- WFIFOW(fd,8) =stor->storage[index].nameid; // id
- WFIFOB(fd,10)=stor->storage[index].identify; //identify flag
- if(stor->storage[index].broken==1)
+ WFIFOW(fd,8) =stor->storage_[index].nameid; // id
+ WFIFOB(fd,10)=stor->storage_[index].identify; //identify flag
+ if(stor->storage_[index].broken==1)
WFIFOB(fd,11)=1; // is weapon broken [Valaris]
else
- WFIFOB(fd,11)=stor->storage[index].attribute; // attribute
- WFIFOB(fd,12)=stor->storage[index].refine; //refine
- if(stor->storage[index].card[0]==0x00ff || stor->storage[index].card[0]==0x00fe || stor->storage[index].card[0]==(short)0xff00) {
- WFIFOW(fd,13)=stor->storage[index].card[0]; //card (4w)
- WFIFOW(fd,15)=stor->storage[index].card[1]; //card (4w)
- WFIFOW(fd,17)=stor->storage[index].card[2]; //card (4w)
- WFIFOW(fd,19)=stor->storage[index].card[3]; //card (4w)
+ WFIFOB(fd,11)=stor->storage_[index].attribute; // attribute
+ WFIFOB(fd,12)=stor->storage_[index].refine; //refine
+ if(stor->storage_[index].card[0]==0x00ff || stor->storage_[index].card[0]==0x00fe || stor->storage_[index].card[0]==(short)0xff00) {
+ WFIFOW(fd,13)=stor->storage_[index].card[0]; //card (4w)
+ WFIFOW(fd,15)=stor->storage_[index].card[1]; //card (4w)
+ WFIFOW(fd,17)=stor->storage_[index].card[2]; //card (4w)
+ WFIFOW(fd,19)=stor->storage_[index].card[3]; //card (4w)
} else {
- if(stor->storage[index].card[0] > 0 && (j=itemdb_viewid(stor->storage[index].card[0])) > 0)
+ if(stor->storage_[index].card[0] > 0 && (j=itemdb_viewid(stor->storage_[index].card[0])) > 0)
WFIFOW(fd,13)= j;
else
- WFIFOW(fd,13)= stor->storage[index].card[0];
- if(stor->storage[index].card[1] > 0 && (j=itemdb_viewid(stor->storage[index].card[1])) > 0)
+ WFIFOW(fd,13)= stor->storage_[index].card[0];
+ if(stor->storage_[index].card[1] > 0 && (j=itemdb_viewid(stor->storage_[index].card[1])) > 0)
WFIFOW(fd,15)= j;
else
- WFIFOW(fd,15)= stor->storage[index].card[1];
- if(stor->storage[index].card[2] > 0 && (j=itemdb_viewid(stor->storage[index].card[2])) > 0)
+ WFIFOW(fd,15)= stor->storage_[index].card[1];
+ if(stor->storage_[index].card[2] > 0 && (j=itemdb_viewid(stor->storage_[index].card[2])) > 0)
WFIFOW(fd,17)= j;
else
- WFIFOW(fd,17)= stor->storage[index].card[2];
- if(stor->storage[index].card[3] > 0 && (j=itemdb_viewid(stor->storage[index].card[3])) > 0)
+ WFIFOW(fd,17)= stor->storage_[index].card[2];
+ if(stor->storage_[index].card[3] > 0 && (j=itemdb_viewid(stor->storage_[index].card[3])) > 0)
WFIFOW(fd,19)= j;
else
- WFIFOW(fd,19)= stor->storage[index].card[3];
+ WFIFOW(fd,19)= stor->storage_[index].card[3];
}
WFIFOSET(fd,packet_len_table[0xf4]);
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index 0acf181..44b45ad 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -201,6 +201,7 @@ int itemdb_isequip2(struct item_data *data)
}
return 0;
}
+
/*==========================================
*
*------------------------------------------
diff --git a/src/map/map.c b/src/map/map.c
index 1acae20..3faf492 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -988,10 +988,10 @@ int map_quit(struct map_session_data *sd) {
pc_cleareventtimer(sd); // イベントタイマを破棄する
- if(sd->state.storage_flag)
- storage_guild_storage_quit(sd,0);
- else
+ if(sd->state.storage_flag == 1)
storage_storage_quit(sd); // 倉庫を開いてるなら保存する
+ else if(sd->state.storage_flag == 2)
+ storage_guild_storage_quit(sd,0);
skill_castcancel(&sd->bl,0); // 詠唱を中断する
skill_stop_dancing(&sd->bl,1);// ダンス/演奏中断
@@ -1023,8 +1023,14 @@ int map_quit(struct map_session_data *sd) {
sd->status.skill[i].flag=0;
}
}
- chrif_save(sd);
- storage_storage_save(sd);
+
+ //The storage closing routines will save the char if needed. [Skotlex]
+ if (!sd->state.storage_flag)
+ chrif_save(sd);
+ else if (sd->state.storage_flag == 1)
+ storage_storageclose(sd);
+ else if (sd->state.storage_flag == 2)
+ storage_guild_storageclose(sd);
if( sd->npc_stackbuf && sd->npc_stackbuf != NULL)
free( sd->npc_stackbuf );
@@ -1805,6 +1811,18 @@ void map_helpscreen() {
exit(1);
}
+int compare_item(struct item *a, struct item *b) {
+ return (
+ (a->nameid == b->nameid) &&
+ (a->identify == b->identify) &&
+ (a->refine == b->refine) &&
+ (a->attribute == b->attribute) &&
+ (a->card[0] == b->card[0]) &&
+ (a->card[1] == b->card[1]) &&
+ (a->card[2] == b->card[2]) &&
+ (a->card[3] == b->card[3]));
+}
+
/*======================================================
* Map-Server Init and Command-line Arguments [Valaris]
*------------------------------------------------------
diff --git a/src/map/map.h b/src/map/map.h
index ceb3bbf..3ebb81c 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -162,7 +162,7 @@ struct map_session_data {
unsigned produce_flag : 1;
unsigned make_arrow_flag : 1;
unsigned potionpitcher_flag : 1;
- unsigned storage_flag : 1;
+ unsigned storage_flag : 2; //0: closed, 1: Normal Storage open, 2: guild storage open [Skotlex]
unsigned shroud_active : 1;
unsigned shroud_hides_name_talking : 1;
unsigned shroud_disappears_on_pickup : 1;
@@ -703,6 +703,7 @@ int map_foreachiddb(int (*)(void*,void*,va_list),...);
void map_addnickdb(struct map_session_data *);
int map_scriptcont(struct map_session_data *sd,int id); /* Continues a script either on a spell or on an NPC */
struct map_session_data * map_nick2sd(char*);
+int compare_item(struct item *a, struct item *b);
struct map_session_data * map_get_first_session();
struct map_session_data * map_get_last_session();
diff --git a/src/map/pc.c b/src/map/pc.c
index 4ad09a3..537e978 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -3485,8 +3485,16 @@ int pc_setpos(struct map_session_data *sd,char *mapname_org,int x,int y,int clrt
sd->bl.y=y;
sd->state.waitingdisconnect=1;
pc_makesavestatus(sd);
- chrif_save(sd);
- storage_storage_save(sd);
+ //The storage close routines save the char data. [Skotlex]
+ if (!sd->state.storage_flag)
+ chrif_save(sd);
+ else if (sd->state.storage_flag == 1)
+ {
+ storage_storageclose(sd);
+ storage_delete(sd->status.account_id);
+ }
+ else if (sd->state.storage_flag == 2)
+ storage_guild_storageclose(sd);
chrif_changemapserver(sd, mapname, x, y, ip, port);
return 0;
}
@@ -7180,7 +7188,6 @@ static int pc_autosave_sub(struct map_session_data *sd,va_list ap)
pc_makesavestatus(sd);
chrif_save(sd);
- storage_storage_save(sd);
for(i=0;i<MAX_GUILDCASTLE;i++){
gc=guild_castle_search(i);
diff --git a/src/map/storage.c b/src/map/storage.c
index 30a8b4c..50f0bef 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -3,18 +3,19 @@
#include <stdlib.h>
#include <string.h>
-#include "db.h"
+#include "../common/db.h"
+#include "../common/nullpo.h"
+#include "../common/malloc.h"
+
+#include "storage.h"
+#include "chrif.h"
#include "itemdb.h"
#include "clif.h"
#include "intif.h"
#include "pc.h"
-#include "storage.h"
#include "guild.h"
-#include "nullpo.h"
-
-#ifdef MEMWATCH
-#include "memwatch.h"
-#endif
+#include "battle.h"
+#include "atcommand.h"
static struct dbt *storage_db;
static struct dbt *guild_storage_db;
@@ -23,32 +24,30 @@ static struct dbt *guild_storage_db;
* 倉庫内アイテムソート
*------------------------------------------
*/
-int storage_comp_item(const void *_i1, const void *_i2){
-struct item *i1=(struct item *)_i1;
-struct item *i2=(struct item *)_i2;
+int storage_comp_item(const void *_i1, const void *_i2)
+{
+ struct item *i1 = (struct item *)_i1;
+ struct item *i2 = (struct item *)_i2;
- if (i1->nameid == i2->nameid) {
+ if (i1->nameid == i2->nameid)
return 0;
- } else if (!(i1->nameid) || !(i1->amount)){
+ else if (!(i1->nameid) || !(i1->amount))
return 1;
- } else if (!(i2->nameid) || !(i2->amount)){
+ else if (!(i2->nameid) || !(i2->amount))
return -1;
- } else {
- return i1->nameid - i2->nameid;
- }
+ return i1->nameid - i2->nameid;
}
-
-void sortage_sortitem(struct storage* stor){
+void sortage_sortitem (struct storage *stor)
+{
nullpo_retv(stor);
-
- qsort(stor->storage, MAX_STORAGE, sizeof(struct item), storage_comp_item);
+ qsort(stor->storage_, MAX_STORAGE, sizeof(struct item), storage_comp_item);
}
-void sortage_gsortitem(struct guild_storage* gstor){
+void sortage_gsortitem (struct guild_storage* gstor)
+{
nullpo_retv(gstor);
-
- qsort(gstor->storage, MAX_GUILD_STORAGE, sizeof(struct item), storage_comp_item);
+ qsort(gstor->storage_, MAX_GUILD_STORAGE, sizeof(struct item), storage_comp_item);
}
/*==========================================
@@ -61,36 +60,72 @@ int do_init_storage(void) // map.c::do_init()から呼ばれる
guild_storage_db=numdb_init();
return 1;
}
+static int guild_storage_db_final(void *key,void *data,va_list ap)
+{
+ struct guild_storage *gstor=(struct guild_storage *) data;
+ free(gstor);
+ return 0;
+}
+static int storage_db_final(void *key,void *data,va_list ap)
+{
+ struct storage *stor=(struct storage *) data;
+ free(stor);
+ return 0;
+}
+void do_final_storage(void) // by [MC Cameri]
+{
+ if (storage_db)
+ numdb_final(storage_db,storage_db_final);
+ if (guild_storage_db)
+ numdb_final(guild_storage_db,guild_storage_db_final);
+}
+
+
+static int storage_reconnect_sub(void *key,void *data,va_list ap)
+{ //Parses storage and saves 'dirty' ones upon reconnect. [Skotlex]
+ int type = va_arg(ap, int);
+ if (type)
+ { //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);
+ }
+ 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);
+ }
+ return 0;
+}
-void do_final_storage(void) // map.c::do_final()から呼ばれる
+//Function to be invoked upon server reconnection to char. To save all 'dirty' storages [Skotlex
+void do_reconnect_storage(void)
{
+ numdb_foreach(storage_db, storage_reconnect_sub, 0);
+ numdb_foreach(guild_storage_db, storage_reconnect_sub, 1);
}
struct storage *account2storage(int account_id)
{
- struct storage *stor;
- stor=numdb_search(storage_db,account_id);
+ struct storage *stor = (struct storage *) numdb_search (storage_db,account_id);
if(stor == NULL) {
- stor = calloc(sizeof(struct storage), 1);
- if(stor == NULL){
- printf("storage: out of memory!\n");
- exit(0);
- }
- memset(stor,0,sizeof(struct storage));
- stor->account_id=account_id;
- numdb_insert(storage_db,stor->account_id,stor);
+ stor = (struct storage *) aCallocA (sizeof(struct storage), 1);
+ stor->account_id = account_id;
+ numdb_insert(storage_db, stor->account_id, stor);
}
return stor;
}
// Just to ask storage, without creation
-struct storage *account2storage2(int account_id) {
- return numdb_search(storage_db, account_id);
+struct storage *account2storage2(int account_id)
+{
+ return (struct storage *) numdb_search(storage_db, account_id);
}
int storage_delete(int account_id)
{
- struct storage *stor = numdb_search(storage_db,account_id);
+ struct storage *stor = (struct storage *) numdb_search(storage_db,account_id);
if(stor) {
numdb_erase(storage_db,account_id);
free(stor);
@@ -104,18 +139,24 @@ int storage_delete(int account_id)
*/
int storage_storageopen(struct map_session_data *sd)
{
+//#ifdef TXT_ONLY
struct storage *stor;
-
+//#endif
nullpo_retr(0, sd);
- if((stor = numdb_search(storage_db,sd->status.account_id)) != NULL) {
- stor->storage_status = 1;
- sd->state.storage_flag = 0;
- clif_storageitemlist(sd,stor);
- clif_storageequiplist(sd,stor);
- clif_updatestorageamount(sd,stor);
- return 0;
+//Storage loading always from sql idea from Komurka [Skotlex] - removed as it opens exploits when server lags.
+//#ifdef TXT_ONLY
+ if((stor = (struct storage *) numdb_search(storage_db,sd->status.account_id)) != NULL) {
+ if (stor->storage_status == 0) {
+ stor->storage_status = 1;
+ sd->state.storage_flag = 1;
+ clif_storageitemlist(sd,stor);
+ clif_storageequiplist(sd,stor);
+ clif_updatestorageamount(sd,stor);
+ return 0;
+ }
} else
+//#endif
intif_request_storage(sd->status.account_id);
return 1;
@@ -142,12 +183,10 @@ int storage_additem(struct map_session_data *sd,struct storage *stor,struct item
if(!itemdb_isequip2(data)){
// 装備品ではないので、既所有品なら個数のみ変化させる
for(i=0;i<MAX_STORAGE;i++){
- if(stor->storage[i].nameid == item_data->nameid &&
- stor->storage[i].card[0] == item_data->card[0] && stor->storage[i].card[1] == item_data->card[1] &&
- stor->storage[i].card[2] == item_data->card[2] && stor->storage[i].card[3] == item_data->card[3]){
- if(stor->storage[i].amount+amount > MAX_AMOUNT)
+ if( compare_item (&stor->storage_[i], item_data)) {
+ if(stor->storage_[i].amount+amount > MAX_AMOUNT)
return 1;
- stor->storage[i].amount+=amount;
+ stor->storage_[i].amount+=amount;
clif_storageitemadded(sd,stor,i,amount);
break;
}
@@ -156,9 +195,9 @@ int storage_additem(struct map_session_data *sd,struct storage *stor,struct item
if(i>=MAX_STORAGE){
// 装備品か未所有品だったので空き欄へ追加
for(i=0;i<MAX_STORAGE;i++){
- if(stor->storage[i].nameid==0){
- memcpy(&stor->storage[i],item_data,sizeof(stor->storage[0]));
- stor->storage[i].amount=amount;
+ if(stor->storage_[i].nameid==0){
+ memcpy(&stor->storage_[i],item_data,sizeof(stor->storage_[0]));
+ stor->storage_[i].amount=amount;
stor->storage_amount++;
clif_storageitemadded(sd,stor,i,amount);
clif_updatestorageamount(sd,stor);
@@ -168,6 +207,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;
}
/*==========================================
@@ -179,17 +220,18 @@ int storage_delitem(struct map_session_data *sd,struct storage *stor,int n,int a
nullpo_retr(1, sd);
nullpo_retr(1, stor);
- if(stor->storage[n].nameid==0 || stor->storage[n].amount<amount)
+ if(stor->storage_[n].nameid==0 || stor->storage_[n].amount<amount)
return 1;
- stor->storage[n].amount-=amount;
- if(stor->storage[n].amount==0){
- memset(&stor->storage[n],0,sizeof(stor->storage[0]));
+ stor->storage_[n].amount-=amount;
+ if(stor->storage_[n].amount==0){
+ memset(&stor->storage_[n],0,sizeof(stor->storage_[0]));
stor->storage_amount--;
clif_updatestorageamount(sd,stor);
}
clif_storageitemremoved(sd,n,amount);
+ stor->dirty = 1;
return 0;
}
/*==========================================
@@ -201,15 +243,16 @@ 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
- if( (amount <= sd->status.inventory[index].amount) && (amount > 0) ) { //valid amount
- if(storage_additem(sd,stor,&sd->status.inventory[index],amount)==0)
- // remove item from inventory
- pc_delitem(sd,index,amount,0);
- } // valid amount
+ if( (amount <= sd->status.inventory[index].amount) && (amount > 0) ) { //valid amount
+// log_tostorage(sd, index, 0);
+ if(storage_additem(sd,stor,&sd->status.inventory[index],amount)==0)
+ // remove item from inventory
+ pc_delitem(sd,index,amount,0);
+ } // valid amount
}// valid index
}// storage not full & storage open
@@ -226,15 +269,16 @@ 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
- if( (amount <= stor->storage[index].amount) && (amount > 0) ) { //valid amount
- if((flag = pc_additem(sd,&stor->storage[index],amount)) == 0)
+ if( (amount <= stor->storage_[index].amount) && (amount > 0) ) { //valid amount
+ if((flag = pc_additem(sd,&stor->storage_[index],amount)) == 0)
storage_delitem(sd,stor,index,amount);
- else
- clif_additem(sd,0,0,flag);
+ //else //taken out because it can dupe items if the above fails somehow :) [Kevin]
+ //clif_additem(sd,0,0,flag);
+// log_fromstorage(sd, index, 0);
} // valid amount
}// valid index
}// storage open
@@ -250,7 +294,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
@@ -273,12 +317,12 @@ 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
- if( (amount <= stor->storage[index].amount) && (amount > 0) ) { //valid amount
- if(pc_cart_additem(sd,&stor->storage[index],amount)==0){
+ if( (amount <= stor->storage_[index].amount) && (amount > 0) ) { //valid amount
+ if(pc_cart_additem(sd,&stor->storage_[index],amount)==0){
storage_delitem(sd,stor,index,amount);
}
} // valid amount
@@ -290,24 +334,21 @@ int storage_storagegettocart(struct map_session_data *sd,int index,int amount)
/*==========================================
- * カプラ倉庫を閉じる
+ * Modified By Valaris to save upon closing [massdriller]
*------------------------------------------
*/
int storage_storageclose(struct map_session_data *sd)
{
- struct storage *stor=NULL;
+ 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));
+ clif_storageclose(sd);
+ chrif_save(sd); //This will invoke the storage save function as well. [Skotlex]
+
stor->storage_status=0;
sd->state.storage_flag = 0;
- clif_storageclose(sd);
-
- chrif_save(sd);
- storage_storage_save(sd);
-
- sortage_sortitem(stor);
return 0;
}
@@ -321,31 +362,64 @@ 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;
+ stor = account2storage2(sd->status.account_id);
+ if(stor) {
+ chrif_save(sd); //Invokes the storage saving as well.
+ stor->storage_status = 0;
+ sd->state.storage_flag = 0;
+ }
return 0;
}
-int storage_storage_save(struct map_session_data *sd)
+void storage_storage_dirty(struct map_session_data *sd)
{
struct storage *stor;
- nullpo_retr(0, sd);
+ stor=account2storage2(sd->status.account_id);
- stor=numdb_search(storage_db,sd->status.account_id);
- if(stor) intif_send_storage(stor);
+ if(stor)
+ stor->dirty = 1;
+}
+
+int storage_storage_save(int account_id)
+{
+ struct storage *stor;
+
+ stor=account2storage2(account_id);
+ if(stor && stor->dirty)
+ {
+ intif_send_storage(stor);
+ return 1;
+ }
return 0;
}
+//Ack from Char-server indicating the storage was saved. [Skotlex]
+int storage_storage_saved(int account_id)
+{
+ struct storage *stor;
+
+ if((stor=account2storage2(account_id)) != NULL)
+ { //Only mark it clean if it's not in use. [Skotlex]
+ if (stor->dirty && stor->storage_status == 0)
+ {
+ stor->dirty = 0;
+ sortage_sortitem(stor);
+ }
+ return 1;
+ }
+ return 0;
+}
+
struct guild_storage *guild2storage(int guild_id)
{
struct guild_storage *gs = NULL;
if(guild_search(guild_id) != NULL) {
- gs=numdb_search(guild_storage_db,guild_id);
+ gs=(struct guild_storage *) numdb_search(guild_storage_db,guild_id);
if(gs == NULL) {
- gs = calloc(sizeof(struct guild_storage), 1);
+ gs = (struct guild_storage *) aCallocA(sizeof(struct guild_storage), 1);
if(gs==NULL){
printf("storage: out of memory!\n");
exit(0);
@@ -357,9 +431,14 @@ struct guild_storage *guild2storage(int guild_id)
return gs;
}
-int guild_storage_delete(int guild_id)
+struct guild_storage *guild2storage2(int guild_id)
+{ //For just locating a storage without creating one. [Skotlex]
+ return (struct guild_storage *) numdb_search(guild_storage_db,guild_id);
+}
+
+int guild_storage_delete(int guild_id)
{
- struct guild_storage *gstor = numdb_search(guild_storage_db,guild_id);
+ struct guild_storage *gstor = (struct guild_storage *) numdb_search(guild_storage_db,guild_id);
if(gstor) {
numdb_erase(guild_storage_db,guild_id);
free(gstor);
@@ -375,11 +454,11 @@ int storage_guild_storageopen(struct map_session_data *sd)
if(sd->status.guild_id <= 0)
return 2;
- if((gstor = numdb_search(guild_storage_db,sd->status.guild_id)) != NULL) {
+ if((gstor = guild2storage2(sd->status.guild_id)) != NULL) {
if(gstor->storage_status)
return 1;
gstor->storage_status = 1;
- sd->state.storage_flag = 1;
+ sd->state.storage_flag = 2;
clif_guildstorageitemlist(sd,gstor);
clif_guildstorageequiplist(sd,gstor);
clif_updateguildstorageamount(sd,gstor);
@@ -411,12 +490,10 @@ int guild_storage_additem(struct map_session_data *sd,struct guild_storage *stor
if(!itemdb_isequip2(data)){
// 装備品ではないので、既所有品なら個数のみ変化させる
for(i=0;i<MAX_GUILD_STORAGE;i++){
- if(stor->storage[i].nameid == item_data->nameid &&
- stor->storage[i].card[0] == item_data->card[0] && stor->storage[i].card[1] == item_data->card[1] &&
- stor->storage[i].card[2] == item_data->card[2] && stor->storage[i].card[3] == item_data->card[3]){
- if(stor->storage[i].amount+amount > MAX_AMOUNT)
+ if(compare_item(&stor->storage_[i], item_data)) {
+ if(stor->storage_[i].amount+amount > MAX_AMOUNT)
return 1;
- stor->storage[i].amount+=amount;
+ stor->storage_[i].amount+=amount;
clif_guildstorageitemadded(sd,stor,i,amount);
break;
}
@@ -425,9 +502,9 @@ int guild_storage_additem(struct map_session_data *sd,struct guild_storage *stor
if(i>=MAX_GUILD_STORAGE){
// 装備品か未所有品だったので空き欄へ追加
for(i=0;i<MAX_GUILD_STORAGE;i++){
- if(stor->storage[i].nameid==0){
- memcpy(&stor->storage[i],item_data,sizeof(stor->storage[0]));
- stor->storage[i].amount=amount;
+ if(stor->storage_[i].nameid==0){
+ memcpy(&stor->storage_[i],item_data,sizeof(stor->storage_[0]));
+ stor->storage_[i].amount=amount;
stor->storage_amount++;
clif_guildstorageitemadded(sd,stor,i,amount);
clif_updateguildstorageamount(sd,stor);
@@ -437,6 +514,7 @@ int guild_storage_additem(struct map_session_data *sd,struct guild_storage *stor
if(i>=MAX_GUILD_STORAGE)
return 1;
}
+ stor->dirty = 1;
return 0;
}
@@ -445,17 +523,17 @@ int guild_storage_delitem(struct map_session_data *sd,struct guild_storage *stor
nullpo_retr(1, sd);
nullpo_retr(1, stor);
- if(stor->storage[n].nameid==0 || stor->storage[n].amount<amount)
+ if(stor->storage_[n].nameid==0 || stor->storage_[n].amount<amount)
return 1;
- stor->storage[n].amount-=amount;
- if(stor->storage[n].amount==0){
- memset(&stor->storage[n],0,sizeof(stor->storage[0]));
+ stor->storage_[n].amount-=amount;
+ if(stor->storage_[n].amount==0){
+ memset(&stor->storage_[n],0,sizeof(stor->storage_[0]));
stor->storage_amount--;
clif_updateguildstorageamount(sd,stor);
}
clif_storageitemremoved(sd,n,amount);
-
+ stor->dirty = 1;
return 0;
}
@@ -465,10 +543,11 @@ int storage_guild_storageadd(struct map_session_data *sd,int index,int amount)
nullpo_retr(0, sd);
- if((stor=guild2storage(sd->status.guild_id)) != NULL) {
+ if((stor=guild2storage2(sd->status.guild_id)) != NULL) {
if( (stor->storage_amount <= MAX_GUILD_STORAGE) && (stor->storage_status == 1) ) { // storage not full & storage open
if(index>=0 && index<MAX_INVENTORY) { // valid index
if( (amount <= sd->status.inventory[index].amount) && (amount > 0) ) { //valid amount
+// log_tostorage(sd, index, 1);
if(guild_storage_additem(sd,stor,&sd->status.inventory[index],amount)==0)
// remove item from inventory
pc_delitem(sd,index,amount,0);
@@ -487,14 +566,15 @@ int storage_guild_storageget(struct map_session_data *sd,int index,int amount)
nullpo_retr(0, sd);
- if((stor=guild2storage(sd->status.guild_id)) != NULL) {
+ if((stor=guild2storage2(sd->status.guild_id)) != NULL) {
if(stor->storage_status == 1) { // storage open
if(index>=0 && index<MAX_GUILD_STORAGE) { // valid index
- if( (amount <= stor->storage[index].amount) && (amount > 0) ) { //valid amount
- if((flag = pc_additem(sd,&stor->storage[index],amount)) == 0)
+ if( (amount <= stor->storage_[index].amount) && (amount > 0) ) { //valid amount
+ if((flag = pc_additem(sd,&stor->storage_[index],amount)) == 0)
guild_storage_delitem(sd,stor,index,amount);
else
clif_additem(sd,0,0,flag);
+// log_fromstorage(sd, index, 1);
} // valid amount
}// valid index
}// storage open
@@ -509,7 +589,7 @@ int storage_guild_storageaddfromcart(struct map_session_data *sd,int index,int a
nullpo_retr(0, sd);
- if((stor=guild2storage(sd->status.guild_id)) != NULL) {
+ if((stor=guild2storage2(sd->status.guild_id)) != NULL) {
if( (stor->storage_amount <= MAX_GUILD_STORAGE) && (stor->storage_status == 1) ) { // storage not full & storage open
if(index>=0 && index<MAX_INVENTORY) { // valid index
if( (amount <= sd->status.cart[index].amount) && (amount > 0) ) { //valid amount
@@ -529,11 +609,11 @@ int storage_guild_storagegettocart(struct map_session_data *sd,int index,int amo
nullpo_retr(0, sd);
- if((stor=guild2storage(sd->status.guild_id)) != NULL) {
+ if((stor=guild2storage2(sd->status.guild_id)) != NULL) {
if(stor->storage_status == 1) { // storage open
if(index>=0 && index<MAX_GUILD_STORAGE) { // valid index
- if( (amount <= stor->storage[index].amount) && (amount > 0) ) { //valid amount
- if(pc_cart_additem(sd,&stor->storage[index],amount)==0){
+ if( (amount <= stor->storage_[index].amount) && (amount > 0) ) { //valid amount
+ if(pc_cart_additem(sd,&stor->storage_[index],amount)==0){
guild_storage_delitem(sd,stor,index,amount);
}
} // valid amount
@@ -544,19 +624,45 @@ int storage_guild_storagegettocart(struct map_session_data *sd,int index,int amo
return 0;
}
+int storage_guild_storagesave(int account_id, int guild_id)
+{
+ struct guild_storage *stor = guild2storage2(guild_id);
+
+ if(stor && stor->dirty)
+ {
+ intif_send_guild_storage(account_id,stor);
+ return 1;
+ }
+ return 0;
+}
+
+int storage_guild_storagesaved(int account_id, int guild_id)
+{
+ struct guild_storage *stor;
+
+ if((stor=guild2storage2(guild_id)) != NULL) {
+ if (stor->dirty && stor->storage_status == 0)
+ { //Storage has been correctly saved.
+ stor->dirty = 0;
+ sortage_gsortitem(stor);
+ }
+ return 1;
+ }
+ return 0;
+}
+
int storage_guild_storageclose(struct map_session_data *sd)
{
struct guild_storage *stor;
nullpo_retr(0, sd);
+ nullpo_retr(0, stor=guild2storage2(sd->status.guild_id));
- if((stor=guild2storage(sd->status.guild_id)) != NULL) {
- intif_send_guild_storage(sd->status.account_id,stor);
- stor->storage_status = 0;
- sd->state.storage_flag = 0;
- sortage_gsortitem(stor);
- }
clif_storageclose(sd);
+ chrif_save(sd); //This one also saves the storage. [Skotlex]
+
+ stor->storage_status=0;
+ sd->state.storage_flag = 0;
return 0;
}
@@ -566,14 +672,16 @@ int storage_guild_storage_quit(struct map_session_data *sd,int flag)
struct guild_storage *stor;
nullpo_retr(0, sd);
+ nullpo_retr(0, stor=guild2storage2(sd->status.guild_id));
- stor = numdb_search(guild_storage_db,sd->status.guild_id);
- if(stor) {
- if(!flag)
- intif_send_guild_storage(sd->status.account_id,stor);
- stor->storage_status = 0;
- sd->state.storage_flag = 0;
- }
+ 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 489741c..774937d 100644
--- a/src/map/storage.h
+++ b/src/map/storage.h
@@ -12,11 +12,14 @@ int storage_storagegettocart(struct map_session_data *sd,int index,int amount);
int storage_storageclose(struct map_session_data *sd);
int do_init_storage(void);
void do_final_storage(void);
+void do_reconnect_storage(void);
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(struct map_session_data *sd);
+int storage_storage_save(int account_id);
+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);
struct guild_storage *guild2storage(int guild_id);
int guild_storage_delete(int guild_id);
@@ -29,6 +32,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_comp_item(const void *_i1, const void *_i2);
//int storage_comp_item(const struct item* i1, const struct item* i2);