mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-23 10:42:25 +00:00
Load converted to QueryDatabase
This commit is contained in:
parent
87efd22394
commit
fd8dc1214c
@ -127,41 +127,31 @@ PersistentTimer::PersistentTimer(uint32 char_id, pTimerType type, uint32 in_star
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool PersistentTimer::Load(Database *db) {
|
bool PersistentTimer::Load(Database *db) {
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
char *query = 0;
|
|
||||||
uint32 qlen = 0;
|
|
||||||
uint32 qcount = 0;
|
|
||||||
|
|
||||||
qlen = MakeAnyLenString(&query, "SELECT start,duration,enable "
|
|
||||||
" FROM timers WHERE char_id=%lu AND type=%u", (unsigned long)_char_id, _type);
|
|
||||||
|
|
||||||
#ifdef DEBUG_PTIMERS
|
#ifdef DEBUG_PTIMERS
|
||||||
printf("Loading timer: char %lu of type %u\n", (unsigned long)_char_id, _type);
|
printf("Loading timer: char %lu of type %u\n", (unsigned long)_char_id, _type);
|
||||||
#endif
|
#endif
|
||||||
|
std::string query = StringFormat("SELECT start, duration, enable "
|
||||||
if (!db->RunQuery(query, qlen, errbuf, &result)) {
|
"FROM timers WHERE char_id=%lu AND type=%u",
|
||||||
safe_delete_array(query);
|
(unsigned long)_char_id, _type);
|
||||||
|
auto results = db->QueryDatabase(query);
|
||||||
|
if (!results.Success()) {
|
||||||
#if EQDEBUG > 5
|
#if EQDEBUG > 5
|
||||||
LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Load, error: %s", errbuf);
|
LogFile->write(EQEMuLog::Error, "Error in PersistentTimer::Load, error: %s", results.ErrorMessage().c_str());
|
||||||
#endif
|
#endif
|
||||||
return(false);
|
return false;
|
||||||
}
|
}
|
||||||
safe_delete_array(query);
|
|
||||||
|
|
||||||
bool res = false;
|
if (results.RowCount() != 1)
|
||||||
qcount = mysql_num_rows(result);
|
return false;
|
||||||
if(qcount == 1 && (row = mysql_fetch_row(result)) ) {
|
|
||||||
start_time = strtoul(row[0], nullptr, 10);
|
|
||||||
timer_time = strtoul(row[1], nullptr, 10);
|
|
||||||
enabled = (row[2][0] == '1');
|
|
||||||
|
|
||||||
res = true;
|
auto row = results.begin();
|
||||||
}
|
|
||||||
mysql_free_result(result);
|
|
||||||
|
|
||||||
return(res);
|
start_time = strtoul(row[0], nullptr, 10);
|
||||||
|
timer_time = strtoul(row[1], nullptr, 10);
|
||||||
|
enabled = (row[2][0] == '1');
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PersistentTimer::Store(Database *db) {
|
bool PersistentTimer::Store(Database *db) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user