mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 13:41:31 +00:00
DeleteBot converted to QueryDatabase
This commit is contained in:
parent
06d1bd632b
commit
515fe8d9e5
63
zone/bot.cpp
63
zone/bot.cpp
@ -4067,44 +4067,41 @@ void Bot::Depop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Bot::DeleteBot(std::string* errorMessage) {
|
bool Bot::DeleteBot(std::string* errorMessage) {
|
||||||
bool Result = false;
|
bool hadError = false;
|
||||||
int TempCounter = 0;
|
|
||||||
|
|
||||||
if(this->GetBotID() > 0) {
|
if(this->GetBotID() == 0)
|
||||||
char* Query = 0;
|
return false;
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
|
|
||||||
// TODO: These queries need to be ran together as a transaction.. ie, if one or more fail then they all will fail to commit to the database.
|
// TODO: These queries need to be ran together as a transaction.. ie, if one or more fail then they all will fail to commit to the database.
|
||||||
|
std::string query = StringFormat("DELETE FROM botinventory WHERE botid = '%u'", this->GetBotID());
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "DELETE FROM botinventory WHERE botid = '%u'", this->GetBotID()), TempErrorMessageBuffer)) {
|
auto results = database.QueryDatabase(query);
|
||||||
*errorMessage = std::string(TempErrorMessageBuffer);
|
if(!results.Success()) {
|
||||||
}
|
*errorMessage = std::string(results.ErrorMessage());
|
||||||
else
|
hadError = true;
|
||||||
TempCounter++;
|
|
||||||
|
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "DELETE FROM botbuffs WHERE botid = '%u'", this->GetBotID()), TempErrorMessageBuffer)) {
|
|
||||||
*errorMessage = std::string(TempErrorMessageBuffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
TempCounter++;
|
|
||||||
|
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "DELETE FROM botstances WHERE BotID = '%u'", this->GetBotID()), TempErrorMessageBuffer)) {
|
|
||||||
*errorMessage = std::string(TempErrorMessageBuffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
TempCounter++;
|
|
||||||
|
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "DELETE FROM bots WHERE BotID = '%u'", this->GetBotID()), TempErrorMessageBuffer)) {
|
|
||||||
*errorMessage = std::string(TempErrorMessageBuffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
TempCounter++;
|
|
||||||
|
|
||||||
if(TempCounter == 4)
|
|
||||||
Result = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
query = StringFormat("DELETE FROM botbuffs WHERE botid = '%u'", this->GetBotID());
|
||||||
|
results = database.QueryDatabase(query);
|
||||||
|
if(!results.Success()) {
|
||||||
|
*errorMessage = std::string(results.ErrorMessage());
|
||||||
|
hadError = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
query = StringFormat("DELETE FROM botstances WHERE BotID = '%u'", this->GetBotID());
|
||||||
|
results = database.QueryDatabase(query);
|
||||||
|
if(!results.Success()) {
|
||||||
|
*errorMessage = std::string(results.ErrorMessage());
|
||||||
|
hadError = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
query = StringFormat("DELETE FROM bots WHERE BotID = '%u'", this->GetBotID());
|
||||||
|
results = database.QueryDatabase(query);
|
||||||
|
if(!results.Success()) {
|
||||||
|
*errorMessage = std::string(results.ErrorMessage());
|
||||||
|
hadError = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !hadError;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::Spawn(Client* botCharacterOwner, std::string* errorMessage) {
|
void Bot::Spawn(Client* botCharacterOwner, std::string* errorMessage) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user