mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 05:21:29 +00:00
CanLoadBotGroup converted to QueryDatabase
This commit is contained in:
parent
fe6e289606
commit
52d64d03a6
50
zone/bot.cpp
50
zone/bot.cpp
@ -4820,43 +4820,31 @@ bool Bot::DoesBotGroupNameExist(std::string botGroupName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 Bot::CanLoadBotGroup(uint32 botOwnerCharacterId, std::string botGroupName, std::string* errorMessage) {
|
uint32 Bot::CanLoadBotGroup(uint32 botOwnerCharacterId, std::string botGroupName, std::string* errorMessage) {
|
||||||
uint32 result = 0;
|
|
||||||
|
|
||||||
if(botOwnerCharacterId > 0 && !botGroupName.empty()) {
|
if(botOwnerCharacterId == 0 || botGroupName.empty())
|
||||||
char ErrBuf[MYSQL_ERRMSG_SIZE];
|
return 0;
|
||||||
char* Query = 0;
|
|
||||||
MYSQL_RES* DatasetResult;
|
|
||||||
MYSQL_ROW DataRow;
|
|
||||||
|
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "select BotGroupId, BotGroupName from vwBotGroups where BotOwnerCharacterId = %u", botOwnerCharacterId), ErrBuf, &DatasetResult)) {
|
std::string query = StringFormat("SELECT BotGroupId, BotGroupName FROM vwBotGroups "
|
||||||
*errorMessage = std::string(ErrBuf);
|
"WHERE BotOwnerCharacterId = %u", botOwnerCharacterId);
|
||||||
}
|
auto results = database.QueryDatabase(query);
|
||||||
else {
|
if(!results.Success()) {
|
||||||
uint32 RowCount = mysql_num_rows(DatasetResult);
|
*errorMessage = std::string(results.ErrorMessage());
|
||||||
|
return 0;
|
||||||
if(RowCount > 0) {
|
|
||||||
for(int iCounter = 0; iCounter < RowCount; iCounter++) {
|
|
||||||
DataRow = mysql_fetch_row(DatasetResult);
|
|
||||||
|
|
||||||
if(DataRow) {
|
|
||||||
uint32 tempBotGroupId = atoi(DataRow[0]);
|
|
||||||
std::string tempBotGroupName = std::string(DataRow[1]);
|
|
||||||
|
|
||||||
if(botGroupName == tempBotGroupName) {
|
|
||||||
result = tempBotGroupId;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mysql_free_result(DatasetResult);
|
if(results.RowCount() == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for(auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
|
||||||
|
uint32 tempBotGroupId = atoi(row[0]);
|
||||||
|
std::string tempBotGroupName = std::string(row[1]);
|
||||||
|
|
||||||
|
if(botGroupName == tempBotGroupName)
|
||||||
|
return tempBotGroupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_delete_array(Query);
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Bot::GetBotGroupIdByBotGroupName(std::string botGroupName, std::string* errorMessage) {
|
uint32 Bot::GetBotGroupIdByBotGroupName(std::string botGroupName, std::string* errorMessage) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user