mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-18 15:31:33 +00:00
ListSpawnedBots converted to QueryDatabase
This commit is contained in:
parent
7ae14fffd0
commit
6410f52c9c
42
zone/bot.cpp
42
zone/bot.cpp
@ -4656,38 +4656,28 @@ std::list<BotsAvailableList> Bot::GetBotList(uint32 botOwnerCharacterID, std::st
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::list<SpawnedBotsList> Bot::ListSpawnedBots(uint32 characterID, std::string* errorMessage) {
|
std::list<SpawnedBotsList> Bot::ListSpawnedBots(uint32 characterID, std::string* errorMessage) {
|
||||||
std::list<SpawnedBotsList> Result;
|
std::list<SpawnedBotsList> spawnedBots;
|
||||||
char ErrBuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char* Query = 0;
|
|
||||||
MYSQL_RES* DatasetResult;
|
|
||||||
MYSQL_ROW DataRow;
|
|
||||||
|
|
||||||
if(characterID > 0) {
|
if(characterID == 0)
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT bot_name, zone_name FROM botleader WHERE leaderid=%i", characterID), ErrBuf, &DatasetResult)) {
|
return spawnedBots;
|
||||||
*errorMessage = std::string(ErrBuf);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
uint32 RowCount = mysql_num_rows(DatasetResult);
|
|
||||||
|
|
||||||
if(RowCount > 0) {
|
std::string query = StringFormat("SELECT bot_name, zone_name FROM botleader WHERE leaderid=%i", characterID);
|
||||||
for(int iCounter = 0; iCounter < RowCount; iCounter++) {
|
auto results = database.QueryDatabase(query);
|
||||||
DataRow = mysql_fetch_row(DatasetResult);
|
if(!results.Success()) {
|
||||||
SpawnedBotsList TempSpawnedBotsList;
|
*errorMessage = std::string(results.ErrorMessage());
|
||||||
TempSpawnedBotsList.BotLeaderCharID = characterID;
|
return spawnedBots;
|
||||||
strcpy(TempSpawnedBotsList.BotName, DataRow[0]);
|
|
||||||
strcpy(TempSpawnedBotsList.ZoneName, DataRow[1]);
|
|
||||||
|
|
||||||
Result.push_back(TempSpawnedBotsList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mysql_free_result(DatasetResult);
|
for(auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
SpawnedBotsList spawnedBotsList;
|
||||||
|
spawnedBotsList.BotLeaderCharID = characterID;
|
||||||
|
strcpy(spawnedBotsList.BotName, row[0]);
|
||||||
|
strcpy(spawnedBotsList.ZoneName, row[1]);
|
||||||
|
|
||||||
|
spawnedBots.push_back(spawnedBotsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_delete_array(Query);
|
return spawnedBots;
|
||||||
}
|
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::SaveBotGroup(Group* botGroup, std::string botGroupName, std::string* errorMessage) {
|
void Bot::SaveBotGroup(Group* botGroup, std::string botGroupName, std::string* errorMessage) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user