mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-23 14:52:26 +00:00
GetTimeRemainingInstance converted to QueryDatabase
This commit is contained in:
parent
903a3a9060
commit
9abdf5f4b3
@ -2249,49 +2249,40 @@ uint32 Database::VersionFromInstanceID(uint16 instance_id)
|
|||||||
|
|
||||||
uint32 Database::GetTimeRemainingInstance(uint16 instance_id, bool &is_perma)
|
uint32 Database::GetTimeRemainingInstance(uint16 instance_id, bool &is_perma)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
char *query = nullptr;
|
||||||
char *query = 0;
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
uint32 start_time = 0;
|
uint32 start_time = 0;
|
||||||
uint32 duration = 0;
|
uint32 duration = 0;
|
||||||
uint32 never_expires = 0;
|
uint32 never_expires = 0;
|
||||||
|
|
||||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT start_time, duration, never_expires FROM instance_list WHERE id=%u",
|
auto results = QueryDatabase(query, MakeAnyLenString(&query, "SELECT start_time, duration, never_expires FROM instance_list WHERE id=%u", instance_id));
|
||||||
instance_id), errbuf, &result))
|
safe_delete_array(query);
|
||||||
|
|
||||||
|
if (!results.Success())
|
||||||
{
|
{
|
||||||
safe_delete_array(query);
|
|
||||||
if (mysql_num_rows(result) != 0)
|
|
||||||
{
|
|
||||||
row = mysql_fetch_row(result);
|
|
||||||
start_time = atoi(row[0]);
|
|
||||||
duration = atoi(row[1]);
|
|
||||||
never_expires = atoi(row[2]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mysql_free_result(result);
|
|
||||||
is_perma = false;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
mysql_free_result(result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
safe_delete_array(query);
|
|
||||||
is_perma = false;
|
is_perma = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (results.RowCount() == 0)
|
||||||
|
{
|
||||||
|
is_perma = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
|
||||||
|
start_time = atoi(row[0]);
|
||||||
|
duration = atoi(row[1]);
|
||||||
|
never_expires = atoi(row[2]);
|
||||||
|
|
||||||
if(never_expires == 1)
|
if(never_expires == 1)
|
||||||
{
|
{
|
||||||
is_perma = true;
|
is_perma = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
is_perma = false;
|
||||||
is_perma = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
timeval tv;
|
timeval tv;
|
||||||
gettimeofday(&tv, nullptr);
|
gettimeofday(&tv, nullptr);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user