summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-12-27 11:30:37 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2010-12-27 11:30:37 +0000
commitc82d8121d5c52e42242d9f3f8be36f0aed569701 (patch)
tree9e22f1dec5282717cf32fe6fe7e1697a2289d181 /src/map/pc.c
parentd10cf69aff5fdc4894535e62705de9f6bdfe2672 (diff)
downloadhercules-c82d8121d5c52e42242d9f3f8be36f0aed569701.tar.gz
hercules-c82d8121d5c52e42242d9f3f8be36f0aed569701.tar.bz2
hercules-c82d8121d5c52e42242d9f3f8be36f0aed569701.tar.xz
hercules-c82d8121d5c52e42242d9f3f8be36f0aed569701.zip
* Added item stacking limit database (item_stack.txt) required for runes and other 3rd class related skill items.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/renewal@14635 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 94121eba9..a444c7bba 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -3200,18 +3200,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;
}
@@ -3349,6 +3356,12 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount)
return 5;
data = itemdb_search(item_data->nameid);
+
+ if( data->stack.inventory && amount > data->stack.amount )
+ {// item stack limitation
+ return 5;
+ }
+
w = data->weight*amount;
if(sd->weight + w > sd->max_weight)
return 2;
@@ -3361,7 +3374,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount)
{
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);
@@ -3787,6 +3800,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_isGM(sd)) )
{ // Check item trade restrictions [Skotlex]
clif_displaymessage (sd->fd, msg_txt(264));
@@ -3807,7 +3825,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;