mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-09 17:32:29 +00:00
DeleteBotGroup converted to QueryDatabase
This commit is contained in:
parent
36325226eb
commit
96cf3d967f
33
zone/bot.cpp
33
zone/bot.cpp
@ -4721,27 +4721,26 @@ void Bot::SaveBotGroup(Group* botGroup, std::string botGroupName, std::string* e
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Bot::DeleteBotGroup(std::string botGroupName, std::string* errorMessage) {
|
void Bot::DeleteBotGroup(std::string botGroupName, std::string* errorMessage) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
|
||||||
|
|
||||||
if(!botGroupName.empty()) {
|
if(botGroupName.empty())
|
||||||
uint32 botGroupId = GetBotGroupIdByBotGroupName(botGroupName, errorMessage);
|
return;
|
||||||
|
|
||||||
if(errorMessage->empty() && botGroupId > 0) {
|
uint32 botGroupId = GetBotGroupIdByBotGroupName(botGroupName, errorMessage);
|
||||||
if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE FROM botgroupmembers WHERE BotGroupId = %u", botGroupId), errbuf)) {
|
|
||||||
*errorMessage = std::string(errbuf);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
safe_delete_array(query);
|
|
||||||
|
|
||||||
if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE FROM botgroup WHERE BotGroupId = %u", botGroupId), errbuf)) {
|
if(!errorMessage->empty() || botGroupId== 0)
|
||||||
*errorMessage = std::string(errbuf);
|
return;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
safe_delete_array(query);
|
std::string query = StringFormat("DELETE FROM botgroupmembers WHERE BotGroupId = %u", botGroupId);
|
||||||
}
|
auto results = database.QueryDatabase(query);
|
||||||
}
|
if(!results.Success()) {
|
||||||
|
*errorMessage = std::string(results.ErrorMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
query = StringFormat("DELETE FROM botgroup WHERE BotGroupId = %u", botGroupId);
|
||||||
|
results = database.QueryDatabase(query);
|
||||||
|
if(!results.Success())
|
||||||
|
*errorMessage = std::string(results.ErrorMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<BotGroup> Bot::LoadBotGroup(std::string botGroupName, std::string* errorMessage) {
|
std::list<BotGroup> Bot::LoadBotGroup(std::string botGroupName, std::string* errorMessage) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user