2022-12-30 19:03:37 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use Core\Db;
|
|
|
|
|
|
|
|
|
|
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'autoload.php';
|
|
|
|
|
|
|
|
|
|
/**
|
2023-01-10 16:29:32 +00:00
|
|
|
|
* Скрипт отвечает за чистку пещер которые не используются игроком в течении 3 часов
|
|
|
|
|
* при учете что пещере больше 5 часов от времени создания.
|
2022-12-30 19:03:37 +00:00
|
|
|
|
*
|
2023-01-10 16:29:32 +00:00
|
|
|
|
* Запуск раз в минуту.
|
|
|
|
|
* (3 часа оффлайна на 5 часов существования, зачем тут поминутка?)
|
2022-12-30 19:03:37 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
# Выбираем пещеру (ИД, ГОРОД), где:
|
|
|
|
|
# Игрок в пещере
|
|
|
|
|
# Игрок оффлайн более 3х часов
|
|
|
|
|
# Пещера запущена более 3х часов назад
|
|
|
|
|
# Время пещеры вышло (?!)
|
2022-12-30 19:03:37 +00:00
|
|
|
|
# ??? bsid
|
2023-07-31 17:06:51 +00:00
|
|
|
|
# Это не пещера №15 (было захардкодено)
|
2022-12-30 19:03:37 +00:00
|
|
|
|
|
|
|
|
|
$dungeons = Db::getRows(
|
|
|
|
|
'
|
|
|
|
|
select
|
|
|
|
|
dungeon_now.id as did
|
|
|
|
|
from
|
|
|
|
|
dungeon_now
|
|
|
|
|
left join users on dungeon_now.id = users.id
|
|
|
|
|
left join stats on dungeon_now.id = stats.id
|
|
|
|
|
where
|
|
|
|
|
stats.dnow > 0 and
|
|
|
|
|
users.online < unix_timestamp() - 10800 and
|
|
|
|
|
dungeon_now.time_start < unix_timestamp() - 10800 and
|
|
|
|
|
dungeon_now.time_finish = 0 and
|
2023-07-31 17:06:51 +00:00
|
|
|
|
dungeon_now.bsid = 0 and
|
|
|
|
|
dungeon_now.id != 15
|
2022-12-30 19:03:37 +00:00
|
|
|
|
group by dungeon_now.id order by dungeon_now.id desc
|
|
|
|
|
'
|
|
|
|
|
);
|
|
|
|
|
|
2023-07-31 17:06:51 +00:00
|
|
|
|
$arr = [];
|
|
|
|
|
foreach ($dungeons as $dungeonid) {
|
|
|
|
|
$arr[] = $dungeonid;
|
|
|
|
|
}
|
|
|
|
|
$dungeonids = implode(',', $arr);
|
2022-12-30 19:03:37 +00:00
|
|
|
|
|
2023-07-31 17:06:51 +00:00
|
|
|
|
$stats = Db::getRows('select id from stats where dnow in (?)', [$dungeonids]);
|
|
|
|
|
$arr2 = [];
|
|
|
|
|
foreach ($stats as $statid) {
|
|
|
|
|
$arr2[] = $statid;
|
|
|
|
|
}
|
|
|
|
|
$statids = implode(',', $arr2);
|
2022-12-30 19:03:37 +00:00
|
|
|
|
|
2023-07-31 17:06:51 +00:00
|
|
|
|
# [1] Выкидываем игроков с подземелья и перемещаем его в `321` портал
|
|
|
|
|
Db::sql('update stats set dnow = 0 where id in (?)', [$statids]);
|
|
|
|
|
Db::sql('update users set room = 321 where id in (?)', [$statids]);
|
|
|
|
|
Db::sql('update items_users set `delete` = unix_timestamp() where dn_delete = 1 and uid in (?)', [$statids]);
|
2022-12-30 19:03:37 +00:00
|
|
|
|
|
2023-07-31 17:06:51 +00:00
|
|
|
|
# [2] Удаляем объекты.
|
|
|
|
|
Db::sql('delete from dungeon_obj where for_dn = 0 and dn in (?)', [$dungeonids]);
|
2022-12-30 19:03:37 +00:00
|
|
|
|
|
2023-07-31 17:06:51 +00:00
|
|
|
|
# [3] Удаляем монстров.
|
|
|
|
|
Db::sql('delete from dungeon_bots where for_dn = 0 and dn in (?)', [$dungeonids]);
|
2022-12-30 19:03:37 +00:00
|
|
|
|
|
2023-07-31 17:06:51 +00:00
|
|
|
|
# [4] Удаляем предметы.
|
|
|
|
|
Db::sql('delete from dungeon_items where for_dn = 0 and dn in (?)', [$dungeonids]);
|
2022-12-30 19:03:37 +00:00
|
|
|
|
|
2023-07-31 17:06:51 +00:00
|
|
|
|
# [5] Удаляем действия (actions)
|
|
|
|
|
Db::sql('delete from dungeon_actions where dn in (?)', [$dungeonids]);
|
2022-12-30 19:03:37 +00:00
|
|
|
|
|
2023-07-31 17:06:51 +00:00
|
|
|
|
# [6] Закрываем Подземелье Dungeon_Now - time_finish = time();
|
|
|
|
|
Db::sql('update dungeon_now set time_finish = unix_timestamp() where id in (?)', [$dungeonids]);
|