Fixed invalid purchase history (#6296)

If the items were bought in a random order, this would mess up the purchase history.

Fixes #6284

Thanks to @Lelouzh
This commit is contained in:
Lemongrass3110 2021-10-10 10:42:55 +02:00 committed by GitHub
parent 0eeb464119
commit 58bc89d5db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -227,7 +227,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
// vending item
pc_additem(sd, &vsd->cart.u.items_cart[idx], amount, LOG_TYPE_VENDING);
vsd->vending[vend_list[i]].amount -= amount;
z += ((double)vsd->vending[i].value * (double)amount);
z += ((double)vsd->vending[vend_list[i]].value * (double)amount);
if( vsd->vending[vend_list[i]].amount ) {
if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `amount` = %d WHERE `vending_id` = %d and `cartinventory_id` = %d", vending_items_table, vsd->vending[vend_list[i]].amount, vsd->vender_id, vsd->cart.u.items_cart[idx].id ) != SQL_SUCCESS ) {