mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 09:31:30 +00:00
PurgeExpiredInstances converted to QueryDatabase
This commit is contained in:
parent
010bc76440
commit
3449f5e11c
@ -2370,32 +2370,19 @@ bool Database::CreateInstance(uint16 instance_id, uint32 zone_id, uint32 version
|
|||||||
|
|
||||||
void Database::PurgeExpiredInstances()
|
void Database::PurgeExpiredInstances()
|
||||||
{
|
{
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
char *query = nullptr;
|
||||||
char *query = 0;
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
|
|
||||||
uint16 id = 0;
|
auto results = QueryDatabase(query, MakeAnyLenString(&query, "SELECT id FROM instance_list where (start_time+duration) <= UNIX_TIMESTAMP() and never_expires = 0"));
|
||||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT id FROM instance_list where "
|
safe_delete_array(query);
|
||||||
"(start_time+duration) <= UNIX_TIMESTAMP() and never_expires = 0"), errbuf, &result))
|
|
||||||
{
|
if (!results.Success())
|
||||||
safe_delete_array(query);
|
return;
|
||||||
if (mysql_num_rows(result) > 0)
|
|
||||||
{
|
if (results.RowCount() == 0)
|
||||||
row = mysql_fetch_row(result);
|
return;
|
||||||
while(row != nullptr)
|
|
||||||
{
|
for (auto row = results.begin();row != results.end();++row)
|
||||||
id = atoi(row[0]);
|
DeleteInstance(atoi(row[0]));
|
||||||
DeleteInstance(id);
|
|
||||||
row = mysql_fetch_row(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mysql_free_result(result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
safe_delete_array(query);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::AddClientToInstance(uint16 instance_id, uint32 char_id)
|
bool Database::AddClientToInstance(uint16 instance_id, uint32 char_id)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user