mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-15 04:32:28 +00:00
SaveTimers converted to QueryDatabase
This commit is contained in:
parent
89f34246f0
commit
06d1bd632b
38
zone/bot.cpp
38
zone/bot.cpp
@ -2844,30 +2844,28 @@ void Bot::LoadTimers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Bot::SaveTimers() {
|
void Bot::SaveTimers() {
|
||||||
std::string errorMessage;
|
bool hadError = false;
|
||||||
char* Query = 0;
|
|
||||||
char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE];
|
|
||||||
|
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "DELETE FROM bottimers WHERE BotID = %u;", GetBotID()), TempErrorMessageBuffer)) {
|
std::string query = StringFormat("DELETE FROM bottimers WHERE BotID = %u;", GetBotID());
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
auto results = database.QueryDatabase(query);
|
||||||
safe_delete(Query);
|
if(!results.Success())
|
||||||
Query = 0;
|
hadError = true;
|
||||||
|
|
||||||
|
for(int timerIndex = 0; timerIndex < MaxTimer; timerIndex++) {
|
||||||
|
if(timers[timerIndex] <= Timer::GetCurrentTime())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
query = StringFormat("REPLACE INTO bottimers (BotID, TimerID, Value) VALUES(%u, %u, %u);",
|
||||||
|
GetBotID(), timerIndex+1, timers[timerIndex]);
|
||||||
|
results = database.QueryDatabase(query);
|
||||||
|
|
||||||
|
if(!results.Success())
|
||||||
|
hadError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < MaxTimer; i++) {
|
if(hadError)
|
||||||
if(timers[i] > Timer::GetCurrentTime()) {
|
|
||||||
if(!database.RunQuery(Query, MakeAnyLenString(&Query, "REPLACE INTO bottimers (BotID, TimerID, Value) VALUES(%u, %u, %u);", GetBotID(), i+1, timers[i]), TempErrorMessageBuffer)) {
|
|
||||||
errorMessage = std::string(TempErrorMessageBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
safe_delete(Query);
|
|
||||||
Query = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!errorMessage.empty()) {
|
|
||||||
LogFile->write(EQEMuLog::Error, "Error in Bot::SaveTimers()");
|
LogFile->write(EQEMuLog::Error, "Error in Bot::SaveTimers()");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bot::Process()
|
bool Bot::Process()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user