mirror of
https://github.com/EQEmu/Server.git
synced 2026-02-28 12:22:25 +00:00
DeleteMerc converted to QueryDatabase
This commit is contained in:
parent
17b175daa4
commit
2fd2cd4cec
@ -1582,41 +1582,27 @@ void ZoneDatabase::LoadMercBuffs(Merc *merc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ZoneDatabase::DeleteMerc(uint32 merc_id) {
|
bool ZoneDatabase::DeleteMerc(uint32 merc_id) {
|
||||||
std::string errorMessage;
|
|
||||||
bool Result = false;
|
|
||||||
int TempCounter = 0;
|
|
||||||
|
|
||||||
if(merc_id > 0) {
|
if(merc_id == 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.
|
bool firstQueryWorked = false;
|
||||||
|
// 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 merc_buffs WHERE MercID = '%u'", merc_id);
|
||||||
|
auto results = database.QueryDatabase(query);
|
||||||
|
if(!results.Success())
|
||||||
|
LogFile->write(EQEMuLog::Error, "Error Deleting Merc: %s", results.ErrorMessage().c_str());
|
||||||
|
else
|
||||||
|
firstQueryWorked = true;
|
||||||
|
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "DELETE FROM merc_buffs WHERE MercID = '%u'", merc_id), TempErrorMessageBuffer)) {
|
query = StringFormat("DELETE FROM mercs WHERE MercID = '%u'", merc_id);
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
if(!results.Success()) {
|
||||||
}
|
LogFile->write(EQEMuLog::Error, "Error Deleting Merc: %s", results.ErrorMessage().c_str());
|
||||||
else
|
return false;
|
||||||
TempCounter++;
|
}
|
||||||
|
|
||||||
safe_delete_array(Query);
|
return firstQueryWorked;
|
||||||
|
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "DELETE FROM mercs WHERE MercID = '%u'", merc_id), TempErrorMessageBuffer)) {
|
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
TempCounter++;
|
|
||||||
|
|
||||||
safe_delete_array(Query);
|
|
||||||
|
|
||||||
if(TempCounter == 2)
|
|
||||||
Result = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error Deleting Merc: %s", errorMessage.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDatabase::LoadMercEquipment(Merc *merc) {
|
void ZoneDatabase::LoadMercEquipment(Merc *merc) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user