Prevent opening vending UI multiple times (#6430)

Prevent opening vending UI multiple times in one vending session.
Discard cart modification packet when the player is in a 'can't act' state.

Fixes #3408

Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
This commit is contained in:
Jittapan Pluemsumran 2023-01-04 21:19:26 +07:00 committed by GitHub
parent 3958a96771
commit 857a34832f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 7 deletions

View File

@ -12466,9 +12466,7 @@ void clif_parse_StopAttack(int fd,map_session_data *sd)
/// Request to move an item from inventory to cart (CZ_MOVE_ITEM_FROM_BODY_TO_CART). /// Request to move an item from inventory to cart (CZ_MOVE_ITEM_FROM_BODY_TO_CART).
/// 0126 <index>.W <amount>.L /// 0126 <index>.W <amount>.L
void clif_parse_PutItemToCart( int fd, map_session_data *sd ){ void clif_parse_PutItemToCart( int fd, map_session_data *sd ){
if (pc_istrading(sd)) if (pc_istrading(sd) || !pc_iscarton(sd) || pc_cant_act2(sd))
return;
if (!pc_iscarton(sd))
return; return;
if (map_getmapflag(sd->bl.m, MF_NOUSECART)) if (map_getmapflag(sd->bl.m, MF_NOUSECART))
return; return;
@ -12484,7 +12482,7 @@ void clif_parse_PutItemToCart( int fd, map_session_data *sd ){
void clif_parse_GetItemFromCart(int fd,map_session_data *sd) void clif_parse_GetItemFromCart(int fd,map_session_data *sd)
{ {
struct s_packet_db* info = &packet_db[RFIFOW(fd,0)]; struct s_packet_db* info = &packet_db[RFIFOW(fd,0)];
if (!pc_iscarton(sd)) if (!pc_iscarton(sd) || pc_cant_act2(sd))
return; return;
if (map_getmapflag(sd->bl.m, MF_NOUSECART)) if (map_getmapflag(sd->bl.m, MF_NOUSECART))
return; return;

View File

@ -3514,7 +3514,11 @@ static bool intif_parse_StorageReceived(int fd)
}else if( sd->state.prevend ){ }else if( sd->state.prevend ){
clif_clearcart(sd->fd); clif_clearcart(sd->fd);
clif_cartlist(sd); clif_cartlist(sd);
clif_openvendingreq(sd, sd->vend_skill_lv+2); // Only open the vending UI, if it has not been opened already
if (sd->state.pending_vending_ui) {
clif_openvendingreq(sd, sd->vend_skill_lv + 2);
sd->state.pending_vending_ui = false;
}
} }
break; break;

View File

@ -425,6 +425,7 @@ public:
unsigned int autolooting : 1; //performance-saver, autolooting state for @alootid unsigned int autolooting : 1; //performance-saver, autolooting state for @alootid
unsigned int gmaster_flag : 1; unsigned int gmaster_flag : 1;
unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not. unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.
bool pending_vending_ui; // flag whether the vending packet should still be sent to this player or not
unsigned int warping : 1;//states whether you're in the middle of a warp processing unsigned int warping : 1;//states whether you're in the middle of a warp processing
unsigned int permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc(). unsigned int permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc().
bool hold_recalc; bool hold_recalc;

View File

@ -9019,10 +9019,16 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sd->state.workinprogress = WIP_DISABLE_ALL; sd->state.workinprogress = WIP_DISABLE_ALL;
sd->vend_skill_lv = skill_lv; sd->vend_skill_lv = skill_lv;
ARR_FIND(0, MAX_CART, i, sd->cart.u.items_cart[i].nameid && sd->cart.u.items_cart[i].id == 0); ARR_FIND(0, MAX_CART, i, sd->cart.u.items_cart[i].nameid && sd->cart.u.items_cart[i].id == 0);
if (i < MAX_CART) if (i < MAX_CART) {
// Save the cart before opening the vending UI
sd->state.pending_vending_ui = true;
intif_storage_save(sd, &sd->cart); intif_storage_save(sd, &sd->cart);
else }
else{
// Instantly open the vending UI
sd->state.pending_vending_ui = false;
clif_openvendingreq(sd,2+skill_lv); clif_openvendingreq(sd,2+skill_lv);
}
} }
} }
break; break;