summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2010-11-02 23:06:10 +0000
committerFreeyorp <Freeyorp101@hotmail.com>2010-11-03 14:39:37 +1300
commit0b7c7b425afbfcec0dcf1a2d178ab3c9874d5e7c (patch)
treef1f323248fc75dbfde01b6df912ba05007fe4a5d
parent31c0e0663052977cece542a44fd89cc721461ad7 (diff)
downloadtmwa-0b7c7b425afbfcec0dcf1a2d178ab3c9874d5e7c.tar.gz
tmwa-0b7c7b425afbfcec0dcf1a2d178ab3c9874d5e7c.tar.bz2
tmwa-0b7c7b425afbfcec0dcf1a2d178ab3c9874d5e7c.tar.xz
tmwa-0b7c7b425afbfcec0dcf1a2d178ab3c9874d5e7c.zip
Fix some crashes in cart system.
Also limit using carts only to cartoon players.
-rw-r--r--src/map/pc.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 2b5dc3e..11cd864 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -3808,8 +3808,14 @@ int pc_putitemtocart (struct map_session_data *sd, int idx, int amount)
struct item *item_data;
nullpo_retr (0, sd);
+
+ if (idx < 0 || idx >= MAX_INVENTORY)
+ return 1;
+
nullpo_retr (0, item_data = &sd->status.inventory[idx]);
+ if (!pc_iscarton (sd))
+ return 1;
if (item_data->nameid == 0 || item_data->amount < amount)
return 1;
if (pc_cart_additem (sd, item_data, amount) == 0)
@@ -3827,8 +3833,14 @@ int pc_cartitem_amount (struct map_session_data *sd, int idx, int amount)
struct item *item_data;
nullpo_retr (-1, sd);
+
+ if (idx < 0 || idx >= MAX_CART)
+ return -1;
+
nullpo_retr (-1, item_data = &sd->status.cart[idx]);
+ if (!pc_iscarton (sd))
+ return -1;
if (item_data->nameid == 0 || !item_data->amount)
return -1;
return item_data->amount - amount;
@@ -3845,8 +3857,14 @@ int pc_getitemfromcart (struct map_session_data *sd, int idx, int amount)
int flag;
nullpo_retr (0, sd);
+
+ if (idx < 0 || idx >= MAX_CART)
+ return 1;
+
nullpo_retr (0, item_data = &sd->status.cart[idx]);
+ if (!pc_iscarton (sd))
+ return 1;
if (item_data->nameid == 0 || item_data->amount < amount)
return 1;
if ((flag = pc_additem (sd, item_data, amount)) == 0)