summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-07-13 11:21:33 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-07-13 11:21:33 +0000
commit19acefafcb2677030a84ed3e39383c0a25c2047b (patch)
tree784834075263847f932bbdb06c547af153f5e037 /src/map
parentaa5eb06a2b9087d8765c4e42f3a748259b995315 (diff)
downloadhercules-19acefafcb2677030a84ed3e39383c0a25c2047b.tar.gz
hercules-19acefafcb2677030a84ed3e39383c0a25c2047b.tar.bz2
hercules-19acefafcb2677030a84ed3e39383c0a25c2047b.tar.xz
hercules-19acefafcb2677030a84ed3e39383c0a25c2047b.zip
storage code cleanup (no behavioral changes yet)
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12948 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/charcommand.c2
-rw-r--r--src/map/chrif.c6
-rw-r--r--src/map/clif.c128
-rw-r--r--src/map/clif.h16
-rw-r--r--src/map/intif.c4
-rw-r--r--src/map/storage.c154
-rw-r--r--src/map/storage.h5
7 files changed, 154 insertions, 161 deletions
diff --git a/src/map/charcommand.c b/src/map/charcommand.c
index 4ba77200a..7afcabc15 100644
--- a/src/map/charcommand.c
+++ b/src/map/charcommand.c
@@ -3205,7 +3205,7 @@ int charcommand_storeall(const int fd, struct map_session_data* sd, const char*
if (pl_sd->status.inventory[i].amount) {
if(pl_sd->status.inventory[i].equip != 0)
pc_unequipitem(pl_sd, i, 3);
- storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
+ storage_storageadd(pl_sd, i, sd->status.inventory[i].amount);
}
}
storage_storageclose(pl_sd);
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 87e174e49..57fef3863 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -484,9 +484,11 @@ int chrif_sendmapack(int fd)
//If there are players online, send them to the char-server. [Skotlex]
send_users_tochar();
-
- //Re-save any storages that were modified in the disconnection time. [Skotlex]
+
+ //Auth db reconnect handling
auth_db->foreach(auth_db,chrif_reconnect);
+
+ //Re-save any storages that were modified in the disconnection time. [Skotlex]
do_reconnect_storage();
return 0;
diff --git a/src/map/clif.c b/src/map/clif.c
index b4e309184..21cf8d208 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -3184,124 +3184,107 @@ void clif_tradecompleted(struct map_session_data* sd, int fail)
/*==========================================
* カプラ倉庫のアイテム数を更新
*------------------------------------------*/
-int clif_updatestorageamount(struct map_session_data *sd,struct storage_data *stor)
+void clif_updatestorageamount(struct map_session_data* sd, int amount)
{
int fd;
- nullpo_retr(0, sd);
- nullpo_retr(0, stor);
+ nullpo_retv(sd);
fd=sd->fd;
WFIFOHEAD(fd,packet_len(0xf2));
WFIFOW(fd,0) = 0xf2; // update storage amount
- WFIFOW(fd,2) = stor->storage_amount; //items
+ WFIFOW(fd,2) = amount; //items
WFIFOW(fd,4) = MAX_STORAGE; //items max
WFIFOSET(fd,packet_len(0xf2));
-
- return 0;
}
/*==========================================
* カプラ倉庫にアイテムを追加する
*------------------------------------------*/
-int clif_storageitemadded(struct map_session_data *sd,struct storage_data *stor,int index,int amount)
+void clif_storageitemadded(struct map_session_data* sd, struct item* i, int index, int amount)
{
int view,fd;
- nullpo_retr(0, sd);
- nullpo_retr(0, stor);
+ nullpo_retv(sd);
+ nullpo_retv(i);
fd=sd->fd;
+ view = itemdb_viewid(i->nameid);
#if PACKETVER < 5
WFIFOHEAD(fd,packet_len(0xf4));
- WFIFOW(fd,0) =0xf4; // Storage item added
- WFIFOW(fd,2) =index+1; // index
- WFIFOL(fd,4) =amount; // amount
- if((view = itemdb_viewid(stor->items[index].nameid)) > 0)
- WFIFOW(fd,8) =view;
- else
- WFIFOW(fd,8) =stor->items[index].nameid; // id
- WFIFOB(fd,10)=stor->storage_[index].identify; //identify flag
- WFIFOB(fd,11)=stor->storage_[index].attribute; // attribute
- WFIFOB(fd,12)=stor->storage_[index].refine; //refine
- clif_addcards(WFIFOP(fd,13), &stor->items[index]);
+ WFIFOW(fd, 0) = 0xf4; // Storage item added
+ WFIFOW(fd, 2) = index+1; // index
+ WFIFOL(fd, 4) = amount; // amount
+ WFIFOW(fd, 8) = ( view > 0 ) ? view : i->nameid; // id
+ WFIFOB(fd,10) = i->identify; //identify flag
+ WFIFOB(fd,11) = i->attribute; // attribute
+ WFIFOB(fd,12) = i->refine; //refine
+ clif_addcards(WFIFOP(fd,13), i);
WFIFOSET(fd,packet_len(0xf4));
#else
WFIFOHEAD(fd,packet_len(0x1c4));
- WFIFOW(fd,0) =0x1c4; // Storage item added
- WFIFOW(fd,2) =index+1; // index
- WFIFOL(fd,4) =amount; // amount
- if((view = itemdb_viewid(stor->items[index].nameid)) > 0)
- WFIFOW(fd,8) =view;
- else
- WFIFOW(fd,8) =stor->items[index].nameid; // id
- WFIFOB(fd,10)=itemdb_type(stor->items[index].nameid); //type
- WFIFOB(fd,11)=stor->items[index].identify; //identify flag
- WFIFOB(fd,12)=stor->items[index].attribute; // attribute
- WFIFOB(fd,13)=stor->items[index].refine; //refine
- clif_addcards(WFIFOP(fd,14), &stor->items[index]);
+ WFIFOW(fd, 0) = 0x1c4; // Storage item added
+ WFIFOW(fd, 2) = index+1; // index
+ WFIFOL(fd, 4) = amount; // amount
+ WFIFOW(fd, 8) = ( view > 0 ) ? view : i->nameid; // id
+ WFIFOB(fd,10) = itemdb_type(i->nameid); //type
+ WFIFOB(fd,11) = i->identify; //identify flag
+ WFIFOB(fd,12) = i->attribute; // attribute
+ WFIFOB(fd,13) = i->refine; //refine
+ clif_addcards(WFIFOP(fd,14), i);
WFIFOSET(fd,packet_len(0x1c4));
#endif
-
- return 0;
}
/*==========================================
*
*------------------------------------------*/
-int clif_updateguildstorageamount(struct map_session_data *sd,struct guild_storage *stor)
+void clif_updateguildstorageamount(struct map_session_data* sd, int amount)
{
int fd;
- nullpo_retr(0, sd);
- nullpo_retr(0, stor);
+ nullpo_retv(sd);
fd=sd->fd;
WFIFOHEAD(fd,packet_len(0xf2));
WFIFOW(fd,0) = 0xf2; // update storage amount
- WFIFOW(fd,2) = stor->storage_amount; //items
+ WFIFOW(fd,2) = amount; //items
WFIFOW(fd,4) = MAX_GUILD_STORAGE; //items max
WFIFOSET(fd,packet_len(0xf2));
-
- return 0;
}
/*==========================================
*
*------------------------------------------*/
-int clif_guildstorageitemadded(struct map_session_data *sd,struct guild_storage *stor,int index,int amount)
+void clif_guildstorageitemadded(struct map_session_data* sd, struct item* i, int index, int amount)
{
int view,fd;
- nullpo_retr(0, sd);
- nullpo_retr(0, stor);
-
+ nullpo_retv(sd);
+ nullpo_retv(i);
fd=sd->fd;
+ view = itemdb_viewid(i->nameid);
+
WFIFOHEAD(fd,packet_len(0xf4));
- 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)
- WFIFOW(fd,8) =view;
- else
- WFIFOW(fd,8) =stor->storage_[index].nameid; // id
- WFIFOB(fd,10)=stor->storage_[index].identify; //identify flag
- WFIFOB(fd,11)=stor->storage_[index].attribute; // attribute
- WFIFOB(fd,12)=stor->storage_[index].refine; //refine
- clif_addcards(WFIFOP(fd,13), &stor->storage_[index]);
+ WFIFOW(fd, 0) = 0xf4; // Storage item added
+ WFIFOW(fd, 2) = index+1; // index
+ WFIFOL(fd, 4) = amount; // amount
+ WFIFOW(fd, 8) = ( view > 0 ) ? view : i->nameid; // id
+ WFIFOB(fd,10) = i->identify; //identify flag
+ WFIFOB(fd,11) = i->attribute; // attribute
+ WFIFOB(fd,12) = i->refine; //refine
+ clif_addcards(WFIFOP(fd,13), i);
WFIFOSET(fd,packet_len(0xf4));
-
- return 0;
}
/*==========================================
* カプラ倉庫からアイテムを取り去る
*------------------------------------------*/
-int clif_storageitemremoved(struct map_session_data *sd,int index,int amount)
+void clif_storageitemremoved(struct map_session_data* sd, int index, int amount)
{
int fd;
- nullpo_retr(0, sd);
+ nullpo_retv(sd);
fd=sd->fd;
WFIFOHEAD(fd,packet_len(0xf6));
@@ -3309,25 +3292,21 @@ int clif_storageitemremoved(struct map_session_data *sd,int index,int amount)
WFIFOW(fd,2)=index+1;
WFIFOL(fd,4)=amount;
WFIFOSET(fd,packet_len(0xf6));
-
- return 0;
}
/*==========================================
* カプラ倉庫を閉じる
*------------------------------------------*/
-int clif_storageclose(struct map_session_data *sd)
+void clif_storageclose(struct map_session_data* sd)
{
int fd;
- nullpo_retr(0, sd);
+ nullpo_retv(sd);
fd=sd->fd;
WFIFOHEAD(fd,packet_len(0xf8));
- WFIFOW(fd,0)=0xf8; // Storage Closed
+ WFIFOW(fd,0) = 0xf8; // Storage Closed
WFIFOSET(fd,packet_len(0xf8));
-
- return 0;
}
/*==========================================
@@ -9696,7 +9675,8 @@ void clif_parse_MoveToKafra(int fd, struct map_session_data *sd)
if (sd->state.storage_flag == 1)
storage_storageadd(sd, item_index, item_amount);
- else if (sd->state.storage_flag == 2)
+ else
+ if (sd->state.storage_flag == 2)
storage_guild_storageadd(sd, item_index, item_amount);
}
@@ -9712,7 +9692,8 @@ void clif_parse_MoveFromKafra(int fd,struct map_session_data *sd)
if (sd->state.storage_flag == 1)
storage_storageget(sd, item_index, item_amount);
- else if(sd->state.storage_flag == 2)
+ else
+ if(sd->state.storage_flag == 2)
storage_guild_storageget(sd, item_index, item_amount);
}
@@ -9725,9 +9706,11 @@ void clif_parse_MoveToKafraFromCart(int fd, struct map_session_data *sd)
return;
if (!pc_iscarton(sd))
return;
+
if (sd->state.storage_flag == 1)
storage_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
- else if (sd->state.storage_flag == 2)
+ else
+ if (sd->state.storage_flag == 2)
storage_guild_storageaddfromcart(sd, RFIFOW(fd,2) - 2, RFIFOL(fd,4));
}
@@ -9740,9 +9723,11 @@ void clif_parse_MoveFromKafraToCart(int fd, struct map_session_data *sd)
return;
if (!pc_iscarton(sd))
return;
+
if (sd->state.storage_flag == 1)
storage_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
- else if (sd->state.storage_flag == 2)
+ else
+ if (sd->state.storage_flag == 2)
storage_guild_storagegettocart(sd, RFIFOW(fd,2)-1, RFIFOL(fd,4));
}
@@ -9753,7 +9738,8 @@ void clif_parse_CloseKafra(int fd, struct map_session_data *sd)
{
if (sd->state.storage_flag == 1)
storage_storageclose(sd);
- else if (sd->state.storage_flag == 2)
+ else
+ if (sd->state.storage_flag == 2)
storage_guild_storageclose(sd);
}
diff --git a/src/map/clif.h b/src/map/clif.h
index 500c385af..f3ad31fbe 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -192,14 +192,14 @@ void clif_tradecompleted(struct map_session_data* sd, int fail);
// storage
#include "storage.h"
-void clif_storagelist(struct map_session_data *sd,struct storage_data *stor);
-int clif_updatestorageamount(struct map_session_data *sd,struct storage_data *stor);
-int clif_storageitemadded(struct map_session_data *sd,struct storage_data *stor,int index,int amount);
-int clif_storageitemremoved(struct map_session_data *sd,int index,int amount);
-int clif_storageclose(struct map_session_data *sd);
-void clif_guildstoragelist(struct map_session_data *sd,struct guild_storage *stor);
-int clif_updateguildstorageamount(struct map_session_data *sd,struct guild_storage *stor);
-int clif_guildstorageitemadded(struct map_session_data *sd,struct guild_storage *stor,int index,int amount);
+void clif_storagelist(struct map_session_data* sd, struct storage_data* stor);
+void clif_updatestorageamount(struct map_session_data* sd, int amount);
+void clif_storageitemadded(struct map_session_data* sd, struct item* i, int index, int amount);
+void clif_storageitemremoved(struct map_session_data* sd, int index, int amount);
+void clif_storageclose(struct map_session_data* sd);
+void clif_guildstoragelist(struct map_session_data* sd, struct guild_storage* stor);
+void clif_updateguildstorageamount(struct map_session_data* sd, int amount);
+void clif_guildstorageitemadded(struct map_session_data* sd, struct item* i, int index, int amount);
int clif_insight(struct block_list *,va_list); // map_forallinmovearea callback
int clif_outsight(struct block_list *,va_list); // map_forallinmovearea callback
diff --git a/src/map/intif.c b/src/map/intif.c
index 99e054119..705171f7f 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -1001,7 +1001,7 @@ int intif_parse_LoadStorage(int fd)
stor->storage_status=1;
sd->state.storage_flag = 1;
clif_storagelist(sd,stor);
- clif_updatestorageamount(sd,stor);
+ clif_updatestorageamount(sd,stor->storage_amount);
return 0;
}
@@ -1053,7 +1053,7 @@ int intif_parse_LoadGuildStorage(int fd)
gstor->storage_status = 1;
sd->state.storage_flag = 2;
clif_guildstoragelist(sd,gstor);
- clif_updateguildstorageamount(sd,gstor);
+ clif_updateguildstorageamount(sd,gstor->storage_amount);
return 0;
}
int intif_parse_SaveGuildStorage(int fd)
diff --git a/src/map/storage.c b/src/map/storage.c
index eb6ce0363..964d3008c 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -30,7 +30,7 @@ static DBMap* guild_storage_db; // int guild_id -> struct guild_storage*
/*==========================================
* 倉庫内アイテムソート
*------------------------------------------*/
-int storage_comp_item(const void *_i1, const void *_i2)
+static int storage_comp_item(const void *_i1, const void *_i2)
{
struct item *i1 = (struct item *)_i1;
struct item *i2 = (struct item *)_i2;
@@ -44,13 +44,13 @@ int storage_comp_item(const void *_i1, const void *_i2)
return i1->nameid - i2->nameid;
}
-void storage_sortitem (struct storage_data *stor)
+static void storage_sortitem (struct storage_data *stor)
{
nullpo_retv(stor);
qsort(stor->items, MAX_STORAGE, sizeof(struct item), storage_comp_item);
}
-void storage_gsortitem (struct guild_storage* gstor)
+static void storage_gsortitem (struct guild_storage* gstor)
{
nullpo_retv(gstor);
qsort(gstor->storage_, MAX_GUILD_STORAGE, sizeof(struct item), storage_comp_item);
@@ -90,7 +90,7 @@ static int storage_reconnect_sub(DBKey key,void *data,va_list ap)
return 0;
}
-//Function to be invoked upon server reconnection to char. To save all 'dirty' storages [Skotlex
+//Function to be invoked upon server reconnection to char. To save all 'dirty' storages [Skotlex]
void do_reconnect_storage(void)
{
storage_db->foreach(storage_db, storage_reconnect_sub, 0);
@@ -153,7 +153,7 @@ int storage_storageopen(struct map_session_data *sd)
stor->storage_status = 1;
sd->state.storage_flag = 1;
clif_storagelist(sd,stor);
- clif_updatestorageamount(sd,stor);
+ clif_updatestorageamount(sd,stor->storage_amount);
return 0;
}
@@ -175,29 +175,32 @@ int compare_item(struct item *a, struct item *b)
/*==========================================
* Internal add-item function.
*------------------------------------------*/
-static int storage_additem(struct map_session_data *sd,struct storage_data *stor,struct item *item_data,int amount)
+static int storage_additem(struct map_session_data* sd, struct storage_data* stor,struct item *item_data,int amount)
{
struct item_data *data;
int i;
- if(item_data->nameid <= 0 || amount <= 0)
+ if( item_data->nameid <= 0 || amount <= 0 )
return 1;
data = itemdb_search(item_data->nameid);
- if (!itemdb_canstore(item_data, pc_isGM(sd)))
+ if( !itemdb_canstore(item_data, pc_isGM(sd)) )
{ //Check if item is storable. [Skotlex]
clif_displaymessage (sd->fd, msg_txt(264));
return 1;
}
- if(itemdb_isstackable2(data)){ //Stackable
- for(i=0;i<MAX_STORAGE;i++){
- if( compare_item (&stor->items[i], item_data)) {
- if(amount > MAX_AMOUNT - stor->items[i].amount)
+ if( itemdb_isstackable2(data) )
+ {//Stackable
+ for( i = 0; i < MAX_STORAGE; i++ )
+ {
+ if( compare_item (&stor->items[i], item_data))
+ {// existing items found, stack them
+ if( amount > MAX_AMOUNT - stor->items[i].amount )
return 1;
stor->items[i].amount+=amount;
- clif_storageitemadded(sd,stor,i,amount);
+ clif_storageitemadded(sd,&stor->items[i],i,amount);
stor->dirty = 1;
if(log_config.enable_logs&0x800)
log_pick_pc(sd, "R", item_data->nameid, -amount, item_data);
@@ -205,69 +208,73 @@ static int storage_additem(struct map_session_data *sd,struct storage_data *stor
}
}
}
- //Add item
- for(i=0;i<MAX_STORAGE && stor->items[i].nameid;i++);
-
- if(i>=MAX_STORAGE)
+
+ // find free slot
+ ARR_FIND( 0, MAX_STORAGE, i, stor->items[i].nameid == 0 );
+ if( i >= MAX_STORAGE )
return 1;
+ // add item to slot
memcpy(&stor->items[i],item_data,sizeof(stor->items[0]));
stor->items[i].amount=amount;
stor->storage_amount++;
- clif_storageitemadded(sd,stor,i,amount);
- clif_updatestorageamount(sd,stor);
+ clif_storageitemadded(sd,&stor->items[i],i,amount);
+ clif_updatestorageamount(sd,stor->storage_amount);
stor->dirty = 1;
if(log_config.enable_logs&0x800)
log_pick_pc(sd, "R", item_data->nameid, -amount, item_data);
+
return 0;
}
+
/*==========================================
* Internal del-item function
*------------------------------------------*/
-static int storage_delitem(struct map_session_data *sd,struct storage_data *stor,int n,int amount)
+static int storage_delitem(struct map_session_data* sd, struct storage_data* stor, int n, int amount)
{
-
- if(stor->items[n].nameid==0 || stor->items[n].amount<amount)
+ if( stor->items[n].nameid == 0 || stor->items[n].amount < amount )
return 1;
- stor->items[n].amount-=amount;
- if(log_config.enable_logs&0x800)
+ stor->items[n].amount -= amount;
+
+ if( log_config.enable_logs&0x800 )
log_pick_pc(sd, "R", stor->items[n].nameid, amount, &stor->items[n]);
- if(stor->items[n].amount==0){
+
+ if( stor->items[n].amount == 0 )
+ {
memset(&stor->items[n],0,sizeof(stor->items[0]));
stor->storage_amount--;
- clif_updatestorageamount(sd,stor);
+ clif_updatestorageamount(sd,stor->storage_amount);
}
clif_storageitemremoved(sd,n,amount);
stor->dirty = 1;
return 0;
}
+
/*==========================================
* Add an item to the storage from the inventory.
*------------------------------------------*/
-int storage_storageadd(struct map_session_data *sd,int index,int amount)
+int storage_storageadd(struct map_session_data* sd, int index, int amount)
{
struct storage_data *stor;
nullpo_retr(0, sd);
nullpo_retr(0, stor=account2storage2(sd->status.account_id));
- if((stor->storage_amount > MAX_STORAGE) || !stor->storage_status)
+ if( stor->storage_amount > MAX_STORAGE || !stor->storage_status )
return 0; // storage full / storage closed
- if(index<0 || index>=MAX_INVENTORY)
+ if( index < 0 || index >= MAX_INVENTORY )
return 0;
- if(sd->status.inventory[index].nameid <= 0)
+ if( sd->status.inventory[index].nameid <= 0 )
return 0; //No item on that spot
- if(amount < 1 || amount > sd->status.inventory[index].amount)
+ if( amount < 1 || amount > sd->status.inventory[index].amount )
return 0;
-// log_tostorage(sd, index, 0);
- if(storage_additem(sd,stor,&sd->status.inventory[index],amount)==0)
- // remove item from inventory
+ if( storage_additem(sd,stor,&sd->status.inventory[index],amount) == 0 )
pc_delitem(sd,index,amount,0);
return 1;
@@ -276,7 +283,7 @@ int storage_storageadd(struct map_session_data *sd,int index,int amount)
/*==========================================
* Retrieve an item from the storage.
*------------------------------------------*/
-int storage_storageget(struct map_session_data *sd,int index,int amount)
+int storage_storageget(struct map_session_data* sd, int index, int amount)
{
struct storage_data *stor;
int flag;
@@ -285,45 +292,46 @@ int storage_storageget(struct map_session_data *sd,int index,int amount)
nullpo_retr(0, stor=account2storage2(sd->status.account_id));
- if(index<0 || index>=MAX_STORAGE)
+ if( index < 0 || index >= MAX_STORAGE )
return 0;
- if(stor->items[index].nameid <= 0)
+ if( stor->items[index].nameid <= 0 )
return 0; //Nothing there
- if(amount < 1 || amount > stor->items[index].amount)
+ if( amount < 1 || amount > stor->items[index].amount )
return 0;
- if((flag = pc_additem(sd,&stor->items[index],amount)) == 0)
+ if( (flag = pc_additem(sd,&stor->items[index],amount)) == 0 )
storage_delitem(sd,stor,index,amount);
else
clif_additem(sd,0,0,flag);
-// log_fromstorage(sd, index, 0);
+
return 1;
}
+
/*==========================================
* Move an item from cart to storage.
*------------------------------------------*/
-int storage_storageaddfromcart(struct map_session_data *sd,int index,int amount)
+int storage_storageaddfromcart(struct map_session_data* sd, int index, int amount)
{
struct storage_data *stor;
nullpo_retr(0, sd);
nullpo_retr(0, stor=account2storage2(sd->status.account_id));
- if(stor->storage_amount > MAX_STORAGE || !stor->storage_status)
+ if( stor->storage_amount > MAX_STORAGE || !stor->storage_status )
return 0; // storage full / storage closed
- if(index< 0 || index>=MAX_CART)
+ if( index < 0 || index >= MAX_CART )
return 0;
- if(sd->status.cart[index].nameid <= 0)
+ if( sd->status.cart[index].nameid <= 0 )
return 0; //No item there.
- if(amount < 1 || amount > sd->status.cart[index].amount)
+ if( amount < 1 || amount > sd->status.cart[index].amount )
return 0;
- if(storage_additem(sd,stor,&sd->status.cart[index],amount)==0)
+ if( storage_additem(sd,stor,&sd->status.cart[index],amount) == 0 )
pc_cart_delitem(sd,index,amount,0);
return 1;
@@ -332,26 +340,26 @@ int storage_storageaddfromcart(struct map_session_data *sd,int index,int amount)
/*==========================================
* Get from Storage to the Cart
*------------------------------------------*/
-int storage_storagegettocart(struct map_session_data *sd,int index,int amount)
+int storage_storagegettocart(struct map_session_data* sd, int index, int amount)
{
struct storage_data *stor;
nullpo_retr(0, sd);
nullpo_retr(0, stor=account2storage2(sd->status.account_id));
- if(!stor->storage_status)
+ if( !stor->storage_status )
return 0;
- if(index< 0 || index>=MAX_STORAGE)
+ if( index < 0 || index >= MAX_STORAGE )
return 0;
- if(stor->items[index].nameid <= 0)
+ if( stor->items[index].nameid <= 0 )
return 0; //Nothing there.
- if(amount < 1 || amount > stor->items[index].amount)
+ if( amount < 1 || amount > stor->items[index].amount )
return 0;
- if(pc_cart_additem(sd,&stor->items[index],amount)==0)
+ if( pc_cart_additem(sd,&stor->items[index],amount) == 0 )
storage_delitem(sd,stor,index,amount);
return 1;
@@ -361,7 +369,7 @@ 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)
+int storage_storageclose(struct map_session_data* sd)
{
struct storage_data *stor;
@@ -376,22 +384,23 @@ int storage_storageclose(struct map_session_data *sd)
else
storage_storage_save(sd->status.account_id, 0);
}
- stor->storage_status=0;
- sd->state.storage_flag=0;
+ stor->storage_status = 0;
+ sd->state.storage_flag = 0;
+
return 0;
}
/*==========================================
* When quitting the game.
*------------------------------------------*/
-int storage_storage_quit(struct map_session_data *sd, int flag)
+int storage_storage_quit(struct map_session_data* sd, int flag)
{
struct storage_data *stor;
nullpo_retr(0, sd);
nullpo_retr(0, stor=account2storage2(sd->status.account_id));
- if (stor->storage_status)
+ if( stor->storage_status )
{
if (save_settings&4)
chrif_save(sd, flag); //Invokes the storage saving as well.
@@ -400,10 +409,11 @@ int storage_storage_quit(struct map_session_data *sd, int flag)
}
stor->storage_status = 0;
sd->state.storage_flag = 0;
+
return 0;
}
-void storage_storage_dirty(struct map_session_data *sd)
+void storage_storage_dirty(struct map_session_data* sd)
{
struct storage_data *stor;
@@ -487,7 +497,7 @@ int guild_storage_delete(int guild_id)
return 0;
}
-int storage_guild_storageopen(struct map_session_data *sd)
+int storage_guild_storageopen(struct map_session_data* sd)
{
struct guild_storage *gstor;
@@ -514,11 +524,11 @@ int storage_guild_storageopen(struct map_session_data *sd)
gstor->storage_status = 1;
sd->state.storage_flag = 2;
clif_guildstoragelist(sd,gstor);
- clif_updateguildstorageamount(sd,gstor);
+ clif_updateguildstorageamount(sd,gstor->storage_amount);
return 0;
}
-int guild_storage_additem(struct map_session_data *sd,struct guild_storage *stor,struct item *item_data,int amount)
+int guild_storage_additem(struct map_session_data* sd, struct guild_storage* stor, struct item* item_data, int amount)
{
struct item_data *data;
int i;
@@ -543,7 +553,7 @@ int guild_storage_additem(struct map_session_data *sd,struct guild_storage *stor
if(stor->storage_[i].amount+amount > MAX_AMOUNT)
return 1;
stor->storage_[i].amount+=amount;
- clif_guildstorageitemadded(sd,stor,i,amount);
+ clif_guildstorageitemadded(sd,&stor->storage_[i],i,amount);
stor->dirty = 1;
if(log_config.enable_logs&0x1000)
log_pick_pc(sd, "G", item_data->nameid, -amount, item_data);
@@ -560,15 +570,15 @@ int guild_storage_additem(struct map_session_data *sd,struct guild_storage *stor
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);
+ clif_guildstorageitemadded(sd,&stor->storage_[i],i,amount);
+ clif_updateguildstorageamount(sd,stor->storage_amount);
stor->dirty = 1;
if(log_config.enable_logs&0x1000)
log_pick_pc(sd, "G", item_data->nameid, -amount, item_data);
return 0;
}
-int guild_storage_delitem(struct map_session_data *sd,struct guild_storage *stor,int n,int amount)
+int guild_storage_delitem(struct map_session_data* sd, struct guild_storage* stor, int n, int amount)
{
nullpo_retr(1, sd);
nullpo_retr(1, stor);
@@ -582,14 +592,14 @@ int guild_storage_delitem(struct map_session_data *sd,struct guild_storage *stor
if(stor->storage_[n].amount==0){
memset(&stor->storage_[n],0,sizeof(stor->storage_[0]));
stor->storage_amount--;
- clif_updateguildstorageamount(sd,stor);
+ clif_updateguildstorageamount(sd,stor->storage_amount);
}
clif_storageitemremoved(sd,n,amount);
stor->dirty = 1;
return 0;
}
-int storage_guild_storageadd(struct map_session_data *sd,int index,int amount)
+int storage_guild_storageadd(struct map_session_data* sd, int index, int amount)
{
struct guild_storage *stor;
@@ -615,7 +625,7 @@ int storage_guild_storageadd(struct map_session_data *sd,int index,int amount)
return 1;
}
-int storage_guild_storageget(struct map_session_data *sd,int index,int amount)
+int storage_guild_storageget(struct map_session_data* sd, int index, int amount)
{
struct guild_storage *stor;
int flag;
@@ -644,7 +654,7 @@ int storage_guild_storageget(struct map_session_data *sd,int index,int amount)
return 0;
}
-int storage_guild_storageaddfromcart(struct map_session_data *sd,int index,int amount)
+int storage_guild_storageaddfromcart(struct map_session_data* sd, int index, int amount)
{
struct guild_storage *stor;
@@ -669,7 +679,7 @@ int storage_guild_storageaddfromcart(struct map_session_data *sd,int index,int a
return 1;
}
-int storage_guild_storagegettocart(struct map_session_data *sd,int index,int amount)
+int storage_guild_storagegettocart(struct map_session_data* sd, int index, int amount)
{
struct guild_storage *stor;
@@ -724,7 +734,7 @@ int storage_guild_storagesaved(int guild_id)
return 0;
}
-int storage_guild_storageclose(struct map_session_data *sd)
+int storage_guild_storageclose(struct map_session_data* sd)
{
struct guild_storage *stor;
@@ -745,7 +755,7 @@ int storage_guild_storageclose(struct map_session_data *sd)
return 0;
}
-int storage_guild_storage_quit(struct map_session_data *sd,int flag)
+int storage_guild_storage_quit(struct map_session_data* sd, int flag)
{
struct guild_storage *stor;
diff --git a/src/map/storage.h b/src/map/storage.h
index 20257471a..221bc109d 100644
--- a/src/map/storage.h
+++ b/src/map/storage.h
@@ -41,9 +41,4 @@ int storage_guild_storage_quit(struct map_session_data *sd,int flag);
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);
-void storage_sortitem(struct storage_data* stor);
-void storage_gsortitem(struct guild_storage* gstor);
-
#endif /* _STORAGE_H_ */