mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 11:31:30 +00:00
DoesBotGroupNameExist converted to QueryDatabase
This commit is contained in:
parent
26569ac51d
commit
fe6e289606
40
zone/bot.cpp
40
zone/bot.cpp
@ -4798,39 +4798,25 @@ std::list<BotGroupList> Bot::GetBotGroupListByBotOwnerCharacterId(uint32 botOwne
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Bot::DoesBotGroupNameExist(std::string botGroupName) {
|
bool Bot::DoesBotGroupNameExist(std::string botGroupName) {
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
if(!botGroupName.empty()) {
|
if(botGroupName.empty())
|
||||||
char* Query = 0;
|
return false;
|
||||||
MYSQL_RES* DatasetResult;
|
|
||||||
MYSQL_ROW DataRow;
|
|
||||||
|
|
||||||
if(database.RunQuery(Query, MakeAnyLenString(&Query, "select BotGroupId from vwBotGroups where BotGroupName = '%s'", botGroupName.c_str()), 0, &DatasetResult)) {
|
std::string query = StringFormat("SELECT BotGroupId FROM vwBotGroups "
|
||||||
uint32 RowCount = mysql_num_rows(DatasetResult);
|
"WHERE BotGroupName = '%s'", botGroupName.c_str());
|
||||||
|
auto results = database.QueryDatabase(query);
|
||||||
|
if (!results.Success() || results.RowCount() == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
if(RowCount > 0) {
|
for(auto row = results.begin(); row != results.end(); ++row) {
|
||||||
for(int iCounter = 0; iCounter < RowCount; iCounter++) {
|
uint32 tempBotGroupId = atoi(row[0]);
|
||||||
DataRow = mysql_fetch_row(DatasetResult);
|
std::string tempBotGroupName = std::string(row[1]);
|
||||||
|
|
||||||
if(DataRow) {
|
if (botGroupName == tempBotGroupName && tempBotGroupId != 0)
|
||||||
uint32 tempBotGroupId = atoi(DataRow[0]);
|
return true;
|
||||||
std::string tempBotGroupName = std::string(DataRow[1]);
|
|
||||||
|
|
||||||
if(botGroupName == tempBotGroupName) {
|
|
||||||
result = tempBotGroupId;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mysql_free_result(DatasetResult);
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
safe_delete_array(Query);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Bot::CanLoadBotGroup(uint32 botOwnerCharacterId, std::string botGroupName, std::string* errorMessage) {
|
uint32 Bot::CanLoadBotGroup(uint32 botOwnerCharacterId, std::string botGroupName, std::string* errorMessage) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user