mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 17:26:30 +00:00
SaveTimers converted to QueryDatabase
This commit is contained in:
+18
-20
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user