SendBazaarWelcome converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-09-03 19:39:50 -07:00
parent 091c8ea5f1
commit 6eba672013

View File

@ -1624,18 +1624,10 @@ void Client::BuyTraderItem(TraderBuy_Struct* tbs,Client* Trader,const EQApplicat
void Client::SendBazaarWelcome(){
char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
if (database.RunQuery(query,MakeAnyLenString(&query, "select count(distinct char_id),count(char_id) from trader"),errbuf,&result)){
if(mysql_num_rows(result)==1){
row = mysql_fetch_row(result);
const std::string query = "SELECT COUNT(DISTINCT char_id), count(char_id) FROM trader";
auto results = database.QueryDatabase(query);
if (results.Success() && results.RowCount() == 1){
auto row = results.begin();
EQApplicationPacket* outapp = new EQApplicationPacket(OP_BazaarSearch, sizeof(BazaarWelcome_Struct));
@ -1645,30 +1637,23 @@ void Client::SendBazaarWelcome(){
bws->Beginning.Action = BazaarWelcome;
bws->Items = atoi(row[1]);
bws->Traders = atoi(row[0]);
bws->Items = atoi(row[1]);
QueuePacket(outapp);
safe_delete(outapp);
}
mysql_free_result(result);
}
safe_delete_array(query);
if (database.RunQuery(query,MakeAnyLenString(&query, "select count(distinct charid) from buyer"),errbuf,&result)){
if(mysql_num_rows(result)==1) {
row = mysql_fetch_row(result);
const std::string buyerCountQuery = "SELECT COUNT(DISTINCT charid) FROM buyer";
results = database.QueryDatabase(query);
if (!results.Success() || results.RowCount() != 1)
return;
auto row = results.begin();
Message(10, "There are %i Buyers waiting to purchase your loot. Type /barter to search for them, "
"or use /buyer to set up your own Buy Lines.", atoi(row[0]));
}
mysql_free_result(result);
}
safe_delete_array(query);
}
void Client::SendBazaarResults(uint32 TraderID, uint32 Class_, uint32 Race, uint32 ItemStat, uint32 Slot, uint32 Type,
char Name[64], uint32 MinPrice, uint32 MaxPrice) {