summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorbrianluau <brianluau@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-06-12 16:22:33 +0000
committerbrianluau <brianluau@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-06-12 16:22:33 +0000
commita8fe46e2e80ea5b7d998d3e92717153cc3315129 (patch)
treef023f80fd298226e974c34cf595e4e05e4462a9d /src/map/pc.c
parent22ea2706f0a9767d9910522868cc90f121cfc6fa (diff)
downloadhercules-a8fe46e2e80ea5b7d998d3e92717153cc3315129.tar.gz
hercules-a8fe46e2e80ea5b7d998d3e92717153cc3315129.tar.bz2
hercules-a8fe46e2e80ea5b7d998d3e92717153cc3315129.tar.xz
hercules-a8fe46e2e80ea5b7d998d3e92717153cc3315129.zip
* Merged /branches/renewal/ r14635 Item Stacking System to /trunk (follow up to r15060) pid:106973
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16279 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 26f60c0af..b6f71d8e6 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -3433,19 +3433,25 @@ int pc_modifysellvalue(struct map_session_data *sd,int orig_value)
int pc_checkadditem(struct map_session_data *sd,int nameid,int amount)
{
int i;
+ struct item_data* data;
nullpo_ret(sd);
if(amount > MAX_AMOUNT)
return ADDITEM_OVERAMOUNT;
- if(!itemdb_isstackable(nameid))
+ data = itemdb_search(nameid);
+
+ if(!itemdb_isstackable2(data))
return ADDITEM_NEW;
+ if( data->stack.inventory && amount > data->stack.amount )
+ return ADDITEM_OVERAMOUNT;
+
for(i=0;i<MAX_INVENTORY;i++){
// FIXME: This does not consider the checked item's cards, thus could check a wrong slot for stackability.
if(sd->status.inventory[i].nameid==nameid){
- if(sd->status.inventory[i].amount+amount > MAX_AMOUNT)
+ if( amount > MAX_AMOUNT - sd->status.inventory[i].amount || ( data->stack.inventory && amount > data->stack.amount - sd->status.inventory[i].amount ) )
return ADDITEM_OVERAMOUNT;
return ADDITEM_EXIST;
}
@@ -3644,6 +3650,12 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
return 5;
data = itemdb_search(item_data->nameid);
+
+ if( data->stack.inventory && amount > data->stack.amount )
+ {// item stack limitation
+ return 7;
+ }
+
w = data->weight*amount;
if(sd->weight + w > sd->max_weight)
return 2;
@@ -3664,7 +3676,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
{
if( sd->status.inventory[i].nameid == item_data->nameid && memcmp(&sd->status.inventory[i].card, &item_data->card, sizeof(item_data->card)) == 0 )
{
- if( amount > MAX_AMOUNT - sd->status.inventory[i].amount )
+ if( amount > MAX_AMOUNT - sd->status.inventory[i].amount || ( data->stack.inventory && amount > data->stack.amount - sd->status.inventory[i].amount ) )
return 5;
sd->status.inventory[i].amount += amount;
clif_additem(sd,i,amount,0);
@@ -4122,6 +4134,11 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
return 1;
data = itemdb_search(item_data->nameid);
+ if( data->stack.cart && amount > data->stack.amount )
+ {// item stack limitation
+ return 1;
+ }
+
if( !itemdb_cancartstore(item_data, pc_get_group_level(sd)) )
{ // Check item trade restrictions [Skotlex]
clif_displaymessage (sd->fd, msg_txt(264));
@@ -4142,7 +4159,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
if( i < MAX_CART )
{// item already in cart, stack it
- if(sd->status.cart[i].amount+amount > MAX_AMOUNT)
+ if( amount > MAX_AMOUNT - sd->status.cart[i].amount || ( data->stack.cart && amount > data->stack.amount - sd->status.cart[i].amount ) )
return 1; // no room
sd->status.cart[i].amount+=amount;