mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +00:00
CheckInstanceExpired converted to QueryDatabase
This commit is contained in:
parent
2f3c1ed169
commit
94e4da9456
@ -2178,49 +2178,36 @@ void Database::DeleteInstance(uint16 instance_id)
|
|||||||
|
|
||||||
bool Database::CheckInstanceExpired(uint16 instance_id)
|
bool Database::CheckInstanceExpired(uint16 instance_id)
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
char *query = nullptr;
|
||||||
char *query = 0;
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
|
|
||||||
int32 start_time = 0;
|
int32 start_time = 0;
|
||||||
int32 duration = 0;
|
int32 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",
|
|
||||||
instance_id), errbuf, &result))
|
auto results = QueryDatabase(query, MakeAnyLenString(&query, "SELECT start_time, duration, never_expires FROM instance_list WHERE id=%u", instance_id));
|
||||||
{
|
safe_delete_array(query);
|
||||||
safe_delete_array(query);
|
|
||||||
if (mysql_num_rows(result) != 0)
|
if (!results.Success())
|
||||||
{
|
|
||||||
row = mysql_fetch_row(result);
|
|
||||||
start_time = atoi(row[0]);
|
|
||||||
duration = atoi(row[1]);
|
|
||||||
never_expires = atoi(row[2]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mysql_free_result(result);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
mysql_free_result(result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
safe_delete_array(query);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
if (results.RowCount() == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
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)
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
timeval tv;
|
timeval tv;
|
||||||
gettimeofday(&tv, nullptr);
|
gettimeofday(&tv, nullptr);
|
||||||
|
|
||||||
if((start_time + duration) <= tv.tv_sec)
|
if((start_time + duration) <= tv.tv_sec)
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user