* Fixed bugreport:7844 (merged from Hercules:e3761a8)
This commit is contained in:
@@ -6124,6 +6124,19 @@ void clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail)
|
||||
#endif
|
||||
}
|
||||
|
||||
// [Ind/Hercules] - Data Thanks to Yommy
|
||||
void clif_cart_additem_ack(struct map_session_data *sd, int flag)
|
||||
{
|
||||
int fd;
|
||||
unsigned char *buf;
|
||||
nullpo_retv(sd);
|
||||
|
||||
fd = sd->fd;
|
||||
buf = WFIFOP(fd,0);
|
||||
WBUFW(buf,0) = 0x12c;
|
||||
WBUFL(buf,2) = flag;
|
||||
clif_send(buf,packet_len(0x12c),&sd->bl,SELF);
|
||||
}
|
||||
|
||||
/// Deletes an item from character's cart (ZC_DELETE_ITEM_FROM_CART).
|
||||
/// 0125 <index>.W <amount>.L
|
||||
@@ -10671,12 +10684,15 @@ void clif_parse_StopAttack(int fd,struct map_session_data *sd)
|
||||
void clif_parse_PutItemToCart(int fd,struct map_session_data *sd)
|
||||
{
|
||||
struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)];
|
||||
short flag = 0;
|
||||
if (pc_istrading(sd))
|
||||
return;
|
||||
if (!pc_iscarton(sd))
|
||||
return;
|
||||
pc_putitemtocart(sd,RFIFOW(fd,info->pos[0])-2,
|
||||
RFIFOL(fd,info->pos[1]));
|
||||
if ((flag = pc_putitemtocart(sd,RFIFOW(fd,info->pos[0])-2,RFIFOL(fd,info->pos[1])))) {
|
||||
clif_dropitem(sd,RFIFOW(fd,info->pos[0])-2,0);
|
||||
clif_cart_additem_ack(sd,(flag==1)?ADDITEM_TO_CART_FAIL_WEIGHT:ADDITEM_TO_CART_FAIL_COUNT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -321,6 +321,8 @@ enum clif_messages {
|
||||
SKILL_CANT_USE_AREA = 0x536,
|
||||
VIEW_EQUIP_FAIL = 0x54d,
|
||||
USAGE_FAIL = 0x783,
|
||||
ADDITEM_TO_CART_FAIL_WEIGHT = 0x0,
|
||||
ADDITEM_TO_CART_FAIL_COUNT = 0x1,
|
||||
};
|
||||
|
||||
int clif_setip(const char* ip);
|
||||
@@ -486,6 +488,7 @@ void clif_inventorylist(struct map_session_data *sd);
|
||||
void clif_equiplist(struct map_session_data *sd);
|
||||
|
||||
void clif_cart_additem(struct map_session_data *sd,int n,int amount,int fail);
|
||||
void clif_cart_additem_ack(struct map_session_data *sd, int flag);
|
||||
void clif_cart_delitem(struct map_session_data *sd,int n,int amount);
|
||||
void clif_cartlist(struct map_session_data *sd);
|
||||
void clif_clearcart(int fd);
|
||||
|
||||
@@ -4548,7 +4548,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( amount > MAX_AMOUNT - sd->status.cart[i].amount || ( data->stack.cart && amount > data->stack.amount - sd->status.cart[i].amount ) )
|
||||
return 1; // no room
|
||||
return 2; // no slot
|
||||
|
||||
sd->status.cart[i].amount+=amount;
|
||||
clif_cart_additem(sd,i,amount,0);
|
||||
@@ -4557,7 +4557,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
|
||||
{// item not stackable or not present, add it
|
||||
ARR_FIND( 0, MAX_CART, i, sd->status.cart[i].nameid == 0 );
|
||||
if( i == MAX_CART )
|
||||
return 1; // no room
|
||||
return 2; // no slot
|
||||
|
||||
memcpy(&sd->status.cart[i],item_data,sizeof(sd->status.cart[0]));
|
||||
sd->status.cart[i].amount=amount;
|
||||
@@ -4612,6 +4612,7 @@ int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_
|
||||
int pc_putitemtocart(struct map_session_data *sd,int idx,int amount)
|
||||
{
|
||||
struct item *item_data;
|
||||
short flag;
|
||||
|
||||
nullpo_ret(sd);
|
||||
|
||||
@@ -4623,10 +4624,10 @@ int pc_putitemtocart(struct map_session_data *sd,int idx,int amount)
|
||||
if( item_data->nameid == 0 || amount < 1 || item_data->amount < amount || sd->state.vending )
|
||||
return 1;
|
||||
|
||||
if( pc_cart_additem(sd,item_data,amount,LOG_TYPE_NONE) == 0 )
|
||||
if( (flag = pc_cart_additem(sd,item_data,amount,LOG_TYPE_NONE)) == 0 )
|
||||
return pc_delitem(sd,idx,amount,0,5,LOG_TYPE_NONE);
|
||||
|
||||
return 1;
|
||||
return flag;
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
|
||||
@@ -304,6 +304,7 @@ int storage_storageaddfromcart(struct map_session_data* sd, int index, int amoun
|
||||
*------------------------------------------*/
|
||||
int storage_storagegettocart(struct map_session_data* sd, int index, int amount)
|
||||
{
|
||||
short flag;
|
||||
nullpo_ret(sd);
|
||||
|
||||
if( index < 0 || index >= MAX_STORAGE )
|
||||
@@ -315,8 +316,12 @@ int storage_storagegettocart(struct map_session_data* sd, int index, int amount)
|
||||
if( amount < 1 || amount > sd->status.storage.items[index].amount )
|
||||
return 0;
|
||||
|
||||
if( pc_cart_additem(sd,&sd->status.storage.items[index],amount,LOG_TYPE_STORAGE) == 0 )
|
||||
if( (flag = pc_cart_additem(sd,&sd->status.storage.items[index],amount,LOG_TYPE_STORAGE)) == 0 )
|
||||
storage_delitem(sd,index,amount);
|
||||
else {
|
||||
clif_dropitem(sd,index,0);
|
||||
clif_cart_additem_ack(sd,(flag==1)?ADDITEM_TO_CART_FAIL_WEIGHT:ADDITEM_TO_CART_FAIL_COUNT);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user