mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 12:31:31 +00:00
GetGroupedBotsByGroupID converted to QueryDatabase
This commit is contained in:
parent
ba612f91c7
commit
d213e3b106
35
zone/bot.cpp
35
zone/bot.cpp
@ -4545,31 +4545,24 @@ Bot* Bot::LoadBot(uint32 botID, std::string* errorMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::list<uint32> Bot::GetGroupedBotsByGroupId(uint32 groupId, std::string* errorMessage) {
|
std::list<uint32> Bot::GetGroupedBotsByGroupId(uint32 groupId, std::string* errorMessage) {
|
||||||
std::list<uint32> Result;
|
std::list<uint32> groupedBots;
|
||||||
|
|
||||||
if(groupId > 0) {
|
if(groupId == 0)
|
||||||
char* Query = 0;
|
return groupedBots;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
|
||||||
MYSQL_ROW DataRow;
|
|
||||||
|
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "select g.mobid as BotID from vwGroups as g join bots as b on g.mobid = b.BotId and g.mobtype = 'B' where g.groupid = %u", groupId), TempErrorMessageBuffer, &DatasetResult)) {
|
std::string query = StringFormat("SELECT g.mobid AS BotID FROM vwGroups AS g "
|
||||||
*errorMessage = std::string(TempErrorMessageBuffer);
|
"JOIN bots AS b ON g.mobid = b.BotId AND g.mobtype = 'B' "
|
||||||
}
|
"WHERE g.groupid = %u", groupId);
|
||||||
else {
|
auto results = database.QueryDatabase(query);
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
if(!results.Success()) {
|
||||||
if(DataRow) {
|
*errorMessage = std::string(results.ErrorMessage());
|
||||||
Result.push_back(atoi(DataRow[0]));
|
return groupedBots;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mysql_free_result(DatasetResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
safe_delete_array(Query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
for (auto row = results.begin(); row != results.end(); ++row)
|
||||||
|
groupedBots.push_back(atoi(row[0]));
|
||||||
|
|
||||||
|
return groupedBots;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load and spawn all zoned bots by bot owner character
|
// Load and spawn all zoned bots by bot owner character
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user