|
@@ -196,9 +196,6 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned
|
|
// drop previous results
|
|
// drop previous results
|
|
searchstore_clear(sd);
|
|
searchstore_clear(sd);
|
|
|
|
|
|
- // allocate max. amount of results
|
|
|
|
- sd->searchstore.items = (struct s_search_store_info_item*)aMalloc(sizeof(struct s_search_store_info_item)*battle_config.searchstore_maxresults);
|
|
|
|
-
|
|
|
|
// search
|
|
// search
|
|
s.search_sd = sd;
|
|
s.search_sd = sd;
|
|
s.itemlist = itemlist;
|
|
s.itemlist = itemlist;
|
|
@@ -221,10 +218,7 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned
|
|
|
|
|
|
dbi_destroy(iter);
|
|
dbi_destroy(iter);
|
|
|
|
|
|
- if( sd->searchstore.count ) {
|
|
|
|
- // reclaim unused memory
|
|
|
|
- sd->searchstore.items = (struct s_search_store_info_item*)aRealloc(sd->searchstore.items, sizeof(struct s_search_store_info_item)*sd->searchstore.count);
|
|
|
|
-
|
|
|
|
|
|
+ if( !sd->searchstore.items.empty() ) {
|
|
// present results
|
|
// present results
|
|
clif_search_store_info_ack(sd);
|
|
clif_search_store_info_ack(sd);
|
|
|
|
|
|
@@ -249,7 +243,7 @@ void searchstore_query(struct map_session_data* sd, unsigned char type, unsigned
|
|
*/
|
|
*/
|
|
bool searchstore_querynext(struct map_session_data* sd)
|
|
bool searchstore_querynext(struct map_session_data* sd)
|
|
{
|
|
{
|
|
- if( sd->searchstore.count && ( sd->searchstore.count-1 )/SEARCHSTORE_RESULTS_PER_PAGE > sd->searchstore.pages )
|
|
|
|
|
|
+ if( !sd->searchstore.items.empty() && ( sd->searchstore.items.size()-1 )/SEARCHSTORE_RESULTS_PER_PAGE > sd->searchstore.pages )
|
|
return true;
|
|
return true;
|
|
|
|
|
|
return false;
|
|
return false;
|
|
@@ -261,7 +255,7 @@ bool searchstore_querynext(struct map_session_data* sd)
|
|
*/
|
|
*/
|
|
void searchstore_next(struct map_session_data* sd)
|
|
void searchstore_next(struct map_session_data* sd)
|
|
{
|
|
{
|
|
- if( !battle_config.feature_search_stores || !sd->searchstore.open || sd->searchstore.count <= sd->searchstore.pages*SEARCHSTORE_RESULTS_PER_PAGE ) // nothing (more) to display
|
|
|
|
|
|
+ if( !battle_config.feature_search_stores || !sd->searchstore.open || sd->searchstore.items.size() <= sd->searchstore.pages*SEARCHSTORE_RESULTS_PER_PAGE ) // nothing (more) to display
|
|
return;
|
|
return;
|
|
|
|
|
|
// present results
|
|
// present results
|
|
@@ -279,12 +273,7 @@ void searchstore_clear(struct map_session_data* sd)
|
|
{
|
|
{
|
|
searchstore_clearremote(sd);
|
|
searchstore_clearremote(sd);
|
|
|
|
|
|
- if( sd->searchstore.items ) { // release results
|
|
|
|
- aFree(sd->searchstore.items);
|
|
|
|
- sd->searchstore.items = NULL;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- sd->searchstore.count = 0;
|
|
|
|
|
|
+ sd->searchstore.items.clear();
|
|
sd->searchstore.pages = 0;
|
|
sd->searchstore.pages = 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -315,13 +304,13 @@ void searchstore_click(struct map_session_data* sd, uint32 account_id, int store
|
|
struct map_session_data* pl_sd;
|
|
struct map_session_data* pl_sd;
|
|
searchstore_search_t store_search;
|
|
searchstore_search_t store_search;
|
|
|
|
|
|
- if( !battle_config.feature_search_stores || !sd->searchstore.open || !sd->searchstore.count )
|
|
|
|
|
|
+ if( !battle_config.feature_search_stores || !sd->searchstore.open || sd->searchstore.items.empty() )
|
|
return;
|
|
return;
|
|
|
|
|
|
searchstore_clearremote(sd);
|
|
searchstore_clearremote(sd);
|
|
|
|
|
|
- ARR_FIND( 0, sd->searchstore.count, i, sd->searchstore.items[i].store_id == store_id && sd->searchstore.items[i].account_id == account_id && sd->searchstore.items[i].nameid == nameid );
|
|
|
|
- if( i == sd->searchstore.count ) { // no such result, crafted
|
|
|
|
|
|
+ ARR_FIND( 0, sd->searchstore.items.size(), i, sd->searchstore.items[i]->store_id == store_id && sd->searchstore.items[i]->account_id == account_id && sd->searchstore.items[i]->nameid == nameid );
|
|
|
|
+ if( i == sd->searchstore.items.size() ) { // no such result, crafted
|
|
ShowWarning("searchstore_click: Received request with item %u of account %d, which is not part of current result set (account_id=%d, char_id=%d).\n", nameid, account_id, sd->bl.id, sd->status.char_id);
|
|
ShowWarning("searchstore_click: Received request with item %u of account %d, which is not part of current result set (account_id=%d, char_id=%d).\n", nameid, account_id, sd->bl.id, sd->status.char_id);
|
|
clif_search_store_info_failed(sd, SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE);
|
|
clif_search_store_info_failed(sd, SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE);
|
|
return;
|
|
return;
|
|
@@ -376,7 +365,7 @@ void searchstore_click(struct map_session_data* sd, uint32 account_id, int store
|
|
*/
|
|
*/
|
|
bool searchstore_queryremote(struct map_session_data* sd, uint32 account_id)
|
|
bool searchstore_queryremote(struct map_session_data* sd, uint32 account_id)
|
|
{
|
|
{
|
|
- return (bool)( sd->searchstore.open && sd->searchstore.count && sd->searchstore.remote_id == account_id );
|
|
|
|
|
|
+ return (bool)( sd->searchstore.open && !sd->searchstore.items.empty() && sd->searchstore.remote_id == account_id );
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -387,36 +376,3 @@ void searchstore_clearremote(struct map_session_data* sd)
|
|
{
|
|
{
|
|
sd->searchstore.remote_id = 0;
|
|
sd->searchstore.remote_id = 0;
|
|
}
|
|
}
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Receives results from a store-specific callback.
|
|
|
|
- * @param sd : player requesting
|
|
|
|
- * @param store_id : store ID generated by the client
|
|
|
|
- * @param account_id : account ID of owner's shop
|
|
|
|
- * @param store_name : name of store
|
|
|
|
- * @param nameid : item being searched
|
|
|
|
- * @param amount : count of item
|
|
|
|
- * @param price : zeny price of item
|
|
|
|
- * @param card : card in the item
|
|
|
|
- * @param refine : refine of the item
|
|
|
|
- */
|
|
|
|
-bool searchstore_result(struct map_session_data* sd, int store_id, uint32 account_id, const char* store_name, t_itemid nameid, unsigned short amount, unsigned int price, const t_itemid* card, unsigned char refine, uint8 enchantgrade)
|
|
|
|
-{
|
|
|
|
- struct s_search_store_info_item* ssitem;
|
|
|
|
-
|
|
|
|
- if( sd->searchstore.count >= (unsigned int)battle_config.searchstore_maxresults ) // no more
|
|
|
|
- return false;
|
|
|
|
-
|
|
|
|
- ssitem = &sd->searchstore.items[sd->searchstore.count++];
|
|
|
|
- ssitem->store_id = store_id;
|
|
|
|
- ssitem->account_id = account_id;
|
|
|
|
- safestrncpy(ssitem->store_name, store_name, sizeof(ssitem->store_name));
|
|
|
|
- ssitem->nameid = nameid;
|
|
|
|
- ssitem->amount = amount;
|
|
|
|
- ssitem->price = price;
|
|
|
|
- memcpy(ssitem->card, card, sizeof(ssitem->card));
|
|
|
|
- ssitem->refine = refine;
|
|
|
|
- ssitem->enchantgrade = enchantgrade;
|
|
|
|
-
|
|
|
|
- return true;
|
|
|
|
-}
|
|
|