Fixed pet eggs in the cashshop (#5864)
Fixes #5863 Thanks to @admkakaroto
This commit is contained in:
parent
7a1ea09eb1
commit
b96a87262c
@ -576,35 +576,35 @@ bool cashshop_buylist( struct map_session_data* sd, uint32 kafrapoints, int n, s
|
|||||||
if (!id)
|
if (!id)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!pet_create_egg(sd, nameid)) {
|
unsigned short get_amt = quantity;
|
||||||
unsigned short get_amt = quantity;
|
|
||||||
|
|
||||||
if (id->flag.guid || !itemdb_isstackable2(id))
|
if (id->flag.guid || !itemdb_isstackable2(id))
|
||||||
get_amt = 1;
|
get_amt = 1;
|
||||||
|
|
||||||
#if PACKETVER_SUPPORTS_SALES
|
#if PACKETVER_SUPPORTS_SALES
|
||||||
struct sale_item_data* sale = nullptr;
|
struct sale_item_data* sale = nullptr;
|
||||||
|
|
||||||
if( tab == CASHSHOP_TAB_SALE ){
|
if( tab == CASHSHOP_TAB_SALE ){
|
||||||
sale = sale_find_item( nameid, true );
|
sale = sale_find_item( nameid, true );
|
||||||
|
|
||||||
if( sale == nullptr ){
|
if( sale == nullptr ){
|
||||||
// Client tried to buy an item from sale that was not even on sale
|
// Client tried to buy an item from sale that was not even on sale
|
||||||
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_UNKNOWN );
|
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_UNKNOWN );
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if( sale->amount < quantity ){
|
|
||||||
// Client tried to buy a higher quantity than is available
|
|
||||||
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_UNKNOWN );
|
|
||||||
// Maybe he did not get refreshed in time -> do it now
|
|
||||||
clif_sale_amount( sale, &sd->bl, SELF );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( sale->amount < quantity ){
|
||||||
|
// Client tried to buy a higher quantity than is available
|
||||||
|
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_UNKNOWN );
|
||||||
|
// Maybe he did not get refreshed in time -> do it now
|
||||||
|
clif_sale_amount( sale, &sd->bl, SELF );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (uint32 j = 0; j < quantity; j += get_amt) {
|
for (uint32 j = 0; j < quantity; j += get_amt) {
|
||||||
|
if( !pet_create_egg( sd, nameid ) ){
|
||||||
struct item item_tmp = { 0 };
|
struct item item_tmp = { 0 };
|
||||||
|
|
||||||
item_tmp.nameid = nameid;
|
item_tmp.nameid = nameid;
|
||||||
@ -624,27 +624,27 @@ bool cashshop_buylist( struct map_session_data* sd, uint32 kafrapoints, int n, s
|
|||||||
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_RUNE_OVERCOUNT );
|
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_RUNE_OVERCOUNT );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_SUCCESS );
|
clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_SUCCESS );
|
||||||
|
|
||||||
#if PACKETVER_SUPPORTS_SALES
|
#if PACKETVER_SUPPORTS_SALES
|
||||||
if( tab == CASHSHOP_TAB_SALE ){
|
if( tab == CASHSHOP_TAB_SALE ){
|
||||||
uint32 new_amount = sale->amount - get_amt;
|
uint32 new_amount = sale->amount - get_amt;
|
||||||
|
|
||||||
if( new_amount == 0 ){
|
if( new_amount == 0 ){
|
||||||
sale_remove_item(sale->nameid);
|
sale_remove_item(sale->nameid);
|
||||||
}else{
|
}else{
|
||||||
if( SQL_ERROR == Sql_Query( mmysql_handle, "UPDATE `%s` SET `amount` = '%d' WHERE `nameid` = '%u'", sales_table, new_amount, nameid ) ){
|
if( SQL_ERROR == Sql_Query( mmysql_handle, "UPDATE `%s` SET `amount` = '%d' WHERE `nameid` = '%u'", sales_table, new_amount, nameid ) ){
|
||||||
Sql_ShowDebug(mmysql_handle);
|
Sql_ShowDebug(mmysql_handle);
|
||||||
}
|
|
||||||
|
|
||||||
sale->amount = new_amount;
|
|
||||||
|
|
||||||
clif_sale_amount(sale, NULL, ALL_CLIENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sale->amount = new_amount;
|
||||||
|
|
||||||
|
clif_sale_amount(sale, NULL, ALL_CLIENT);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user