From 3262bee6c5bbdec9ed7392ce541edcd1c796670c Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sat, 23 Aug 2014 23:26:45 -0700 Subject: [PATCH] ExpeditionSay converted to QueryDatabase --- zone/client.cpp | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/zone/client.cpp b/zone/client.cpp index 8b0abda53..b1ed375de 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -8170,29 +8170,21 @@ void Client::PlayMP3(const char* fname) safe_delete(outapp); } -void Client::ExpeditionSay(const char *str, int ExpID) { - char errbuf[MYSQL_ERRMSG_SIZE]; - char* query = 0; - MYSQL_RES *result; - MYSQL_ROW row; +void Client::ExpeditionSay(const char *str, int expID) { - if (!database.RunQuery(query,MakeAnyLenString(&query, "SELECT `player_name` FROM `cust_inst_players` WHERE `inst_id` = %i", ExpID),errbuf,&result)){ - safe_delete_array(query); + std::string query = StringFormat("SELECT `player_name` FROM " + "`cust_inst_players` WHERE " + "`inst_id` = %i", expID); + auto results = database.QueryDatabase(query); + if (!results.Success()) return; + + this->Message(14, "You say to the expedition, '%s'", str); + + for (auto row = results.begin(); row != results.end(); ++row) { + const char* charName = row[0]; + if(strcmp(charName, this->GetCleanName()) != 0) + worldserver.SendEmoteMessage(charName, 0, 0, 14, "%s says to the expedition, '%s'", this->GetCleanName(), str); } - safe_delete_array(query); - - if(result) - this->Message(14, "You say to the expedition, '%s'", str); - - while((row = mysql_fetch_row(result))) { - const char* CharName = row[0]; - if(strcmp(CharName, this->GetCleanName()) != 0) - worldserver.SendEmoteMessage(CharName, 0, 0, 14, "%s says to the expedition, '%s'", this->GetCleanName(), str); - // ChannelList->CreateChannel(ChannelName, ChannelOwner, ChannelPassword, true, atoi(row[3])); - } - - mysql_free_result(result); - }