mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 09:31:30 +00:00
GetBotList converted to QueryDatabase
This commit is contained in:
parent
d213e3b106
commit
7ae14fffd0
45
zone/bot.cpp
45
zone/bot.cpp
@ -4628,38 +4628,31 @@ bool Bot::GroupHasBot(Group* group) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::list<BotsAvailableList> Bot::GetBotList(uint32 botOwnerCharacterID, std::string* errorMessage) {
|
std::list<BotsAvailableList> Bot::GetBotList(uint32 botOwnerCharacterID, std::string* errorMessage) {
|
||||||
std::list<BotsAvailableList> Result;
|
std::list<BotsAvailableList> ownersBots;
|
||||||
|
|
||||||
if(botOwnerCharacterID > 0) {
|
if(botOwnerCharacterID == 0)
|
||||||
char* Query = 0;
|
return ownersBots;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES* DatasetResult;
|
|
||||||
MYSQL_ROW DataRow;
|
|
||||||
|
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT BotID, Name, Class, BotLevel, Race FROM bots WHERE BotOwnerCharacterID = '%u'", botOwnerCharacterID), TempErrorMessageBuffer, &DatasetResult)) {
|
std::string query = StringFormat("SELECT BotID, Name, Class, BotLevel, Race "
|
||||||
*errorMessage = std::string(TempErrorMessageBuffer);
|
"FROM bots WHERE BotOwnerCharacterID = '%u'", botOwnerCharacterID);
|
||||||
}
|
auto results = database.QueryDatabase(query);
|
||||||
else {
|
if(!results.Success()) {
|
||||||
while(DataRow = mysql_fetch_row(DatasetResult)) {
|
*errorMessage = std::string(results.ErrorMessage());
|
||||||
if(DataRow) {
|
return ownersBots;
|
||||||
BotsAvailableList TempAvailableBot;
|
|
||||||
TempAvailableBot.BotID = atoi(DataRow[0]);
|
|
||||||
strcpy(TempAvailableBot.BotName, DataRow[1]);
|
|
||||||
TempAvailableBot.BotClass = atoi(DataRow[2]);
|
|
||||||
TempAvailableBot.BotLevel = atoi(DataRow[3]);
|
|
||||||
TempAvailableBot.BotRace = atoi(DataRow[4]);
|
|
||||||
|
|
||||||
Result.push_back(TempAvailableBot);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mysql_free_result(DatasetResult);
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
BotsAvailableList availableBot;
|
||||||
|
availableBot.BotID = atoi(row[0]);
|
||||||
|
strcpy(availableBot.BotName, row[1]);
|
||||||
|
availableBot.BotClass = atoi(row[2]);
|
||||||
|
availableBot.BotLevel = atoi(row[3]);
|
||||||
|
availableBot.BotRace = atoi(row[4]);
|
||||||
|
|
||||||
|
ownersBots.push_back(availableBot);
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_delete_array(Query);
|
return ownersBots;
|
||||||
}
|
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<SpawnedBotsList> Bot::ListSpawnedBots(uint32 characterID, std::string* errorMessage) {
|
std::list<SpawnedBotsList> Bot::ListSpawnedBots(uint32 characterID, std::string* errorMessage) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user