Fixed searchstores incorrectly updating uses (#8491)
This commit is contained in:
@@ -19148,6 +19148,9 @@ void clif_buyingstore_trade_failed_seller( map_session_data* sd, short result, t
|
||||
/// amount of card slots. If the client does not know about the item it
|
||||
/// cannot be searched.
|
||||
static void clif_parse_SearchStoreInfo( int fd, map_session_data *sd ){
|
||||
if (!battle_config.feature_search_stores)
|
||||
return;
|
||||
|
||||
const PACKET_CZ_SEARCH_STORE_INFO* p = reinterpret_cast<PACKET_CZ_SEARCH_STORE_INFO*>( RFIFOP( fd, 0 ) );
|
||||
|
||||
// minimum packet length
|
||||
@@ -19200,6 +19203,9 @@ static void clif_parse_SearchStoreInfo( int fd, map_session_data *sd ){
|
||||
/// 1 = "next" label to retrieve more results
|
||||
void clif_search_store_info_ack( map_session_data& sd ){
|
||||
#if PACKETVER_MAIN_NUM >= 20100817 || PACKETVER_RE_NUM >= 20100706 || defined(PACKETVER_ZERO)
|
||||
if (!battle_config.feature_search_stores)
|
||||
return;
|
||||
|
||||
uint32 start = sd.searchstore.pages * SEARCHSTORE_RESULTS_PER_PAGE ;
|
||||
uint32 end = umin( static_cast<uint32>( sd.searchstore.items.size() ), start + SEARCHSTORE_RESULTS_PER_PAGE );
|
||||
|
||||
@@ -19260,6 +19266,9 @@ void clif_search_store_info_ack( map_session_data& sd ){
|
||||
/// 0837 <reason>.B (ZC_SEARCH_STORE_INFO_FAILED)
|
||||
void clif_search_store_info_failed(map_session_data& sd, e_searchstore_failure reason){
|
||||
#if PACKETVER_MAIN_NUM >= 20100601 || PACKETVER_RE_NUM >= 20100601 || defined(PACKETVER_ZERO)
|
||||
if (!battle_config.feature_search_stores)
|
||||
return;
|
||||
|
||||
PACKET_ZC_SEARCH_STORE_INFO_FAILED packet{};
|
||||
|
||||
packet.packetType = HEADER_ZC_SEARCH_STORE_INFO_FAILED;
|
||||
@@ -19272,8 +19281,10 @@ void clif_search_store_info_failed(map_session_data& sd, e_searchstore_failure r
|
||||
|
||||
/// Request to display next page of results.
|
||||
/// 0838 (CZ_SEARCH_STORE_INFO_NEXT_PAGE)
|
||||
static void clif_parse_SearchStoreInfoNextPage(int fd, map_session_data* sd)
|
||||
{
|
||||
static void clif_parse_SearchStoreInfoNextPage(int fd, map_session_data* sd){
|
||||
if (!battle_config.feature_search_stores)
|
||||
return;
|
||||
|
||||
searchstore_next(*sd);
|
||||
}
|
||||
|
||||
@@ -19282,6 +19293,9 @@ static void clif_parse_SearchStoreInfoNextPage(int fd, map_session_data* sd)
|
||||
/// 083a <effect>.W <remaining uses>.B (ZC_OPEN_SEARCH_STORE_INFO)
|
||||
void clif_open_search_store_info(map_session_data& sd){
|
||||
#if PACKETVER_MAIN_NUM >= 20100701 || PACKETVER_RE_NUM >= 20100701 || defined(PACKETVER_ZERO)
|
||||
if (!battle_config.feature_search_stores)
|
||||
return;
|
||||
|
||||
PACKET_ZC_OPEN_SEARCH_STORE_INFO packet{};
|
||||
|
||||
packet.packetType = HEADER_ZC_OPEN_SEARCH_STORE_INFO;
|
||||
@@ -19297,8 +19311,10 @@ void clif_open_search_store_info(map_session_data& sd){
|
||||
|
||||
/// Request to close the store search window.
|
||||
/// 083b (CZ_CLOSE_SEARCH_STORE_INFO)
|
||||
static void clif_parse_CloseSearchStoreInfo(int fd, map_session_data* sd)
|
||||
{
|
||||
static void clif_parse_CloseSearchStoreInfo(int fd, map_session_data* sd){
|
||||
if (!battle_config.feature_search_stores)
|
||||
return;
|
||||
|
||||
searchstore_close(*sd);
|
||||
}
|
||||
|
||||
@@ -19306,6 +19322,9 @@ static void clif_parse_CloseSearchStoreInfo(int fd, map_session_data* sd)
|
||||
/// Request to invoke catalog effect on a store from search results.
|
||||
/// 083c <account id>.L <store id>.L <nameid>.W (CZ_SSILIST_ITEM_CLICK)
|
||||
static void clif_parse_SearchStoreInfoListItemClick( int fd, map_session_data* sd ){
|
||||
if (!battle_config.feature_search_stores)
|
||||
return;
|
||||
|
||||
const PACKET_CZ_SSILIST_ITEM_CLICK* p = reinterpret_cast<PACKET_CZ_SSILIST_ITEM_CLICK*>( RFIFOP( fd, 0 ) );
|
||||
|
||||
searchstore_click( *sd, p->AID, p->storeId, p->itemId );
|
||||
@@ -19316,6 +19335,9 @@ static void clif_parse_SearchStoreInfoListItemClick( int fd, map_session_data* s
|
||||
/// 083d <xPos>.W <yPos>.W (ZC_SSILIST_ITEM_CLICK_ACK)
|
||||
void clif_search_store_info_click_ack(map_session_data& sd, int16 x, int16 y){
|
||||
#if PACKETVER_MAIN_NUM >= 20100608 || PACKETVER_RE_NUM >= 20100608 || defined(PACKETVER_ZERO)
|
||||
if (!battle_config.feature_search_stores)
|
||||
return;
|
||||
|
||||
PACKET_ZC_SSILIST_ITEM_CLICK_ACK packet{};
|
||||
|
||||
packet.packetType = HEADER_ZC_SSILIST_ITEM_CLICK_ACK;
|
||||
|
||||
@@ -22427,6 +22427,11 @@ BUILDIN_FUNC(buyingstore)
|
||||
/// searchstores <uses>,<effect>{,<map name>};
|
||||
BUILDIN_FUNC(searchstores)
|
||||
{
|
||||
if (!battle_config.feature_search_stores) {
|
||||
ShowError("buildin_searchstores: Search stores feature is disabled.\n");
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
|
||||
map_session_data* sd;
|
||||
|
||||
if( !script_rid2sd(sd) )
|
||||
|
||||
@@ -87,7 +87,7 @@ static int searchstore_getstoreid(map_session_data& sd, e_searchstore_searchtype
|
||||
*/
|
||||
bool searchstore_open(map_session_data& sd, uint16 uses, e_searchstore_effecttype effect, int16 mapid)
|
||||
{
|
||||
if( !battle_config.feature_search_stores || sd.searchstore.open )
|
||||
if( sd.searchstore.open )
|
||||
return false;
|
||||
|
||||
|
||||
@@ -121,9 +121,6 @@ void searchstore_query(map_session_data& sd, e_searchstore_searchtype type, unsi
|
||||
searchstore_searchall_t store_searchall;
|
||||
time_t querytime;
|
||||
|
||||
if( !battle_config.feature_search_stores )
|
||||
return;
|
||||
|
||||
if( !sd.searchstore.open )
|
||||
return;
|
||||
|
||||
@@ -144,11 +141,22 @@ void searchstore_query(map_session_data& sd, e_searchstore_searchtype type, unsi
|
||||
return;
|
||||
}
|
||||
|
||||
// uses counter must be updated before validating the next search
|
||||
sd.searchstore.uses--;
|
||||
sd.searchstore.type = type;
|
||||
sd.searchstore.nextquerytime = querytime + battle_config.searchstore_querydelay;
|
||||
|
||||
// drop previous results
|
||||
searchstore_clear(sd);
|
||||
|
||||
// validate lists
|
||||
for( i = 0; i < item_count; i++ ) {
|
||||
if( !item_db.exists(itemlist[i].itemId) ) {
|
||||
ShowWarning("searchstore_query: Client resolved item %u is not known.\n", itemlist[i].itemId);
|
||||
clif_search_store_info_failed(sd, SSI_FAILED_NOTHING_SEARCH_ITEM);
|
||||
|
||||
// update uses
|
||||
clif_search_store_info_ack(sd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -156,6 +164,9 @@ void searchstore_query(map_session_data& sd, e_searchstore_searchtype type, unsi
|
||||
if( !item_db.exists(cardlist[i].itemId) ) {
|
||||
ShowWarning("searchstore_query: Client resolved card %u is not known.\n", cardlist[i].itemId);
|
||||
clif_search_store_info_failed(sd, SSI_FAILED_NOTHING_SEARCH_ITEM);
|
||||
|
||||
// update uses
|
||||
clif_search_store_info_ack(sd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -163,13 +174,6 @@ void searchstore_query(map_session_data& sd, e_searchstore_searchtype type, unsi
|
||||
if( max_price < min_price )
|
||||
std::swap(min_price, max_price);
|
||||
|
||||
sd.searchstore.uses--;
|
||||
sd.searchstore.type = type;
|
||||
sd.searchstore.nextquerytime = querytime+battle_config.searchstore_querydelay;
|
||||
|
||||
// drop previous results
|
||||
searchstore_clear(sd);
|
||||
|
||||
// search
|
||||
s.search_sd = &sd;
|
||||
s.itemlist = itemlist;
|
||||
@@ -207,11 +211,11 @@ void searchstore_query(map_session_data& sd, e_searchstore_searchtype type, unsi
|
||||
// cleanup
|
||||
searchstore_clear(sd);
|
||||
|
||||
// notify of failure (must go before updating uses)
|
||||
clif_search_store_info_failed(sd, SSI_FAILED_NOTHING_SEARCH_ITEM);
|
||||
|
||||
// update uses
|
||||
clif_search_store_info_ack( sd );
|
||||
|
||||
// notify of failure
|
||||
clif_search_store_info_failed(sd, SSI_FAILED_NOTHING_SEARCH_ITEM);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +238,7 @@ bool searchstore_querynext(map_session_data& sd)
|
||||
*/
|
||||
void searchstore_next(map_session_data& sd)
|
||||
{
|
||||
if( !battle_config.feature_search_stores || !sd.searchstore.open || sd.searchstore.items.size() <= sd.searchstore.pages*SEARCHSTORE_RESULTS_PER_PAGE ) // nothing (more) to display
|
||||
if( !sd.searchstore.open || sd.searchstore.items.size() <= sd.searchstore.pages*SEARCHSTORE_RESULTS_PER_PAGE ) // nothing (more) to display
|
||||
return;
|
||||
|
||||
// present results
|
||||
@@ -283,7 +287,7 @@ void searchstore_click(map_session_data& sd, uint32 account_id, int store_id, t_
|
||||
map_session_data* pl_sd;
|
||||
searchstore_search_t store_search;
|
||||
|
||||
if( !battle_config.feature_search_stores || !sd.searchstore.open || sd.searchstore.items.empty() )
|
||||
if( !sd.searchstore.open || sd.searchstore.items.empty() )
|
||||
return;
|
||||
|
||||
searchstore_clearremote(sd);
|
||||
|
||||
Reference in New Issue
Block a user