GetBotGroupLeaderIdByBotGroupName converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-09-03 18:13:15 -07:00
parent 6d33a13e23
commit 45320fd8ec

View File

@ -4868,34 +4868,17 @@ uint32 Bot::GetBotGroupIdByBotGroupName(std::string botGroupName, std::string* e
} }
uint32 Bot::GetBotGroupLeaderIdByBotGroupName(std::string botGroupName) { uint32 Bot::GetBotGroupLeaderIdByBotGroupName(std::string botGroupName) {
uint32 result = 0;
if(!botGroupName.empty()) { if(botGroupName.empty())
char* Query = 0; return 0;
MYSQL_RES* DatasetResult;
MYSQL_ROW DataRow;
if(database.RunQuery(Query, MakeAnyLenString(&Query, "select BotGroupLeaderBotId from vwBotGroups where BotGroupName = '%s'", botGroupName.c_str()), 0, &DatasetResult)) { std::string query = StringFormat("SELECT BotGroupLeaderBotId FROM vwBotGroups WHERE BotGroupName = '%s'", botGroupName.c_str());
uint32 RowCount = mysql_num_rows(DatasetResult); auto results = database.QueryDatabase(query);
if (!results.Success() || results.RowCount() == 0)
return 0;
if(RowCount > 0) { auto row = results.begin();
for(int iCounter = 0; iCounter < RowCount; iCounter++) { return atoi(row[0]);
DataRow = mysql_fetch_row(DatasetResult);
if(DataRow) {
result = atoi(DataRow[0]);
break;
}
}
}
mysql_free_result(DatasetResult);
}
safe_delete_array(Query);
}
return result;
} }
uint32 Bot::AllowedBotSpawns(uint32 botOwnerCharacterID, std::string* errorMessage) { uint32 Bot::AllowedBotSpawns(uint32 botOwnerCharacterID, std::string* errorMessage) {