diff --git a/_incl_data/class/Dungeon.php b/_incl_data/class/Dungeon.php
index 7cd9383a..a9f3ec82 100644
--- a/_incl_data/class/Dungeon.php
+++ b/_incl_data/class/Dungeon.php
@@ -28,6 +28,18 @@ class Dungeon
4 => [1 => 4, 2 => 1, 3 => 2, 4 => 3],
];
+ /**
+ * 1-9: передняя стенка, в 2-х шагах;
+ * 10-23: растояние: 1 шаг;
+ * 24: стена прямо слева от персонажа;
+ * 25: стена прямо справа от персонажа;
+ * 26: стена прямо перед персонажем;
+ * 27: стена слева от персонажа;
+ * 28: стена справа от персонажа;
+ * @var array
+ */
+ public readonly array $walls;
+
public function __construct(User $user = null)
{
if (!$user) {
@@ -1522,7 +1534,7 @@ class Dungeon
//Розыгрыш предмета
- public function genMatix()
+ public function genMatix(): array
{
$r = [];
if ($this->gs == 1) {
@@ -1619,101 +1631,109 @@ class Dungeon
global $u;
$this->cord['x']++;
$this->cord[($u->info['y'] + $y) . '_' . ($u->info['x'] + $x)] = $this->cord['x'];
- return $this->map[0][($u->info['y'] + $y) . '_' . ($u->info['x'] + $x)];
+ return $this->map[0][($u->info['y'] + $y) . '_' . ($u->info['x'] + $x)] ?? [];
}
- public function lookDungeon()
+ private function lookDungeon()
{
- global $u, $c, $code, $pd;
- /* Генерируем изображение карты */ /* LEVEL 1 */
+ $pd = array_fill(1, 28, 0);
- // Исправления от 29/10/2014 относительно D5, 2 этаж, ПТП. Покрутиться и все гуд. и от 22/11/2014 для обратных стен. Если стена к нам задницей, мы её не видим.
- if ($this->testSt(2, 4) > 0 /* || $this->testSt(3,2)>0 */) {
+ global $pd;
+ /* Генерируем изображение карты */
+
+ /* LEVEL 1 */
+ if ($this->testSt(2, 4)) {
$pd[28] = 1;
}
- if (/*$this->testSt(1,4)>0 ||*/ $this->testSt(2, 2) > 0) {
+ if ($this->testSt(2, 2)) {
$pd[27] = 1;
}
- if ($this->testSt(2, 1) > 0 /*|| $this->testSt(5,3)>0*/) {
+ if ($this->testSt(2, 1)) {
$pd[26] = 1;
}
- if ($this->testSt(3, 1) > 0/* || $this->testSt(6,3)>0*/) {
+ if ($this->testSt(3, 1)) {
$pd[25] = 1;
}
- if ($this->testSt(1, 1) > 0 /*|| $this->testSt(4,3)>0*/) {
+ if ($this->testSt(1, 1)) {
$pd[24] = 1;
}
+
/* LEVEL 2 */
- if ($this->testSt(5, 4) > 0 /*|| $this->testSt(6,2)>0*/) {
+ if ($this->testSt(5, 4)) {
$pd[23] = 1;
}
- if (/*$this->testSt(4,4)>0 || */ $this->testSt(5, 2) > 0) {
+ if ($this->testSt(5, 2)) {
$pd[22] = 1;
}
- if ($this->testSt(5, 1) > 0 /*|| $this->testSt(8,3)>0*/) {
+ if ($this->testSt(5, 1)) {
$pd[21] = 1;
}
- if ($this->testSt(6, 1) > 0 /*|| $this->testSt(7,3)>0*/) {
+ if ($this->testSt(6, 1)) {
$pd[20] = 1;
}
- if ($this->testSt(4, 1) > 0/* || $this->testSt(9,3)>0*/) {
+ if ($this->testSt(4, 1)) {
$pd[19] = 1;
}
/* LEVEL 3 */
- if ($this->testSt(8, 4) > 0 /*|| $this->testSt(7,2)>0*/) {
+ if ($this->testSt(8, 4)) {
$pd[18] = 1;
}
- if (/*$this->testSt(9,4)>0 || */ $this->testSt(8, 2) > 0) {
+ if ($this->testSt(8, 2)) {
$pd[17] = 1;
}
- if ($this->testSt(8, 1) > 0 /* || $this->testSt(12,3)>0*/) {
+ if ($this->testSt(8, 1)) {
$pd[16] = 1;
}
- if ($this->testSt(7, 1) > 0 /* || $this->testSt(13,3)>0*/) {
+ if ($this->testSt(7, 1)) {
$pd[15] = 1;
}
- if ($this->testSt(9, 1) > 0 /*|| $this->testSt(11,3)>0*/) {
+ if ($this->testSt(9, 1)) {
$pd[14] = 1;
}
/* LEVEL 4 */
-
- if ($this->testSt(12, 4) > 0 || $this->testSt(13, 2) > 0) {
+ if ($this->testSt(12, 4) || $this->testSt(13, 2)) {
$pd[13] = 1;
}
- if ($this->testSt(12, 2) > 0 || $this->testSt(11, 4) > 0) {
+ if ($this->testSt(12, 2) || $this->testSt(11, 4)) {
$pd[12] = 1;
}
- if ($this->testSt(13, 1) > 0 || $this->testSt(17, 3) > 0) {
+ if ($this->testSt(13, 1) || $this->testSt(17, 3)) {
$pd[11] = 1;
} //8
- if ($this->testSt(11, 1) > 0 || $this->testSt(16, 3) > 0) {
+ if ($this->testSt(11, 1) || $this->testSt(16, 3)) {
$pd[10] = 1;
} //7
- if ($this->testSt(12, 1) > 0/* || $this->testSt(15,3)>0*/) {
+ if ($this->testSt(12, 1)) {
$pd[9] = 1;
}
- if ($this->testSt(14, 1) > 0 || $this->testSt(18, 3) > 0) {
+ if ($this->testSt(14, 1) || $this->testSt(18, 3)) {
$pd[6] = 1;
} //2
- if ($this->testSt(10, 1) > 0 || $this->testSt(19, 3) > 0) {
+ if ($this->testSt(10, 1) || $this->testSt(19, 3)) {
$pd[5] = 1;
} //1
- if ($this->testSt(16, 4) > 0 || $this->testSt(15, 2) > 0) {
+ if ($this->testSt(16, 4) || $this->testSt(15, 2)) {
$pd[4] = 1;
}
- if ($this->testSt(15, 4) > 0 || $this->testSt(17, 2) > 0) {
+ if ($this->testSt(15, 4) || $this->testSt(17, 2)) {
$pd[3] = 1;
}
+ $this->walls = $pd;
/* Генерируем предметы на карте */
/* Генерируем персонажей и ботов на карте */
}
- public function testSt($id, $s)
+ /** Видим ли мы стену?
+ * @param int $id
+ * @param int $s в какую сторону смотрим
+ * @return bool
+ */
+ private function testSt(int $id, int $s): bool
{
$r = 0;
//заменяем отображение стен в зависимости от угла обзора
@@ -1721,7 +1741,7 @@ class Dungeon
if (isset($this->map[1][$id]['id'])) {
$r = $this->map[1][$id]['st'][($s - 1)];
}
- return $r;
+ return $r > 0;
}
public function initPoint(int $x, int $y): void
@@ -1740,8 +1760,6 @@ class Dungeon
}
$tou = 0; //какому юзеру предназначено
/* выделяем случайного юзера из команды */
- $itmnm = mysql_fetch_assoc(mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $itm . '" LIMIT 1'));
- $itmnm = $itmnm['name'];
$asex = '';
if ($u->info['sex'] == 1) {
$asex = 'а';
@@ -1773,17 +1791,11 @@ class Dungeon
return true;
}
- public function n_lead($who, $lead)
+ public function n_lead(string $who, int $lead): void
{
- global $u, $c, $code;
+ global $u;
- $to = mysql_fetch_assoc(
- mysql_query(
- 'SELECT `u`.`id`, `u`.`login`, `st`.`id`, `st`.`dnow` FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON (`u`.`id` = `st`.`id`) WHERE `u`.`login` = "' . mysql_real_escape_string(
- $who
- ) . '" LIMIT 1'
- )
- );
+ $to = Db::getRow('select stats.id, dnow from users left join stats on users.id = stats.id where login = ?', [$who]);
if ($this->info['uid'] != $lead) {
$this->error = 'Вы не лидер...';
@@ -1799,29 +1811,23 @@ class Dungeon
);
if ($u->info['sex'] == 0) {
$this->sys_chat(
- '' . $u->info['login'] . ' передал лидерство в группе персонажу ' . $to['login'] . ''
+ '' . $u->info['login'] . ' передал лидерство в группе персонажу ' . $who . ''
);
} else {
$this->sys_chat(
- '' . $u->info['login'] . ' передала лидерство в группе персонажу ' . $to['login'] . ''
+ '' . $u->info['login'] . ' передала лидерство в группе персонажу ' . $who . ''
);
}
- //header('Location: main.php');
- die('');
+
+ exit("");
}
}
- public function go_to_hell($who, $lead)
+ public function go_to_hell(string $who, int $lead): void
{
- global $u, $c, $code;
+ global $u;
- $to = mysql_fetch_assoc(
- mysql_query(
- 'SELECT `u`.`id`, `u`.`login`, `st`.`id`, `st`.`dnow` FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON (`u`.`id` = `st`.`id`) WHERE `u`.`login` = "' . mysql_real_escape_string(
- $who
- ) . '" LIMIT 1'
- )
- );
+ $to = Db::getRow('select stats.id, dnow from users left join stats on users.id = stats.id where login = ?', [$who]);
if ($this->info['uid'] != $lead) {
$this->error = 'Вы не лидер...';
@@ -1837,8 +1843,6 @@ class Dungeon
$rb = 209; // Вход в ледяную пещеру
} elseif ($u->info['room'] == 396) {
$rb = 395; // Канализация (Ангелс)
- } elseif ($u->info['room'] == 398) {
- $rb = 321; // Все пещеры
} elseif ($this->info['id2'] == 3) {
$rb = 293; // Вход в Катакомбы
} elseif ($this->info['id2'] == 1) {
@@ -1847,15 +1851,9 @@ class Dungeon
$rb = 275; // Гора Легиона
} elseif ($this->info['id2'] == 12) {
$rb = 372; // Вход в Пещеру Тысячи Проклятий
- } elseif ($this->info['id2'] == 444) {
- $rb = 321; // Вход в пещеру инкв
- } elseif ($this->info['id2'] == 31) {
- $rb = 321; // Вход в пещеру инкв
- } elseif ($this->info['id2'] == 101) {
- $rb = 321; // Вход в Бездну
-
}
+
$sp = mysql_query('SELECT * FROM `dungeon_now` WHERE `time_finish` = "0" LIMIT 50');
while ($pl = mysql_fetch_assoc($sp)) {
$cn = mysql_fetch_assoc(
@@ -1891,14 +1889,15 @@ class Dungeon
if ($u->info['sex'] == 0) {
$this->sys_chat(
- '' . $u->info['login'] . ' выгнал из похода персонажа ' . $to['login'] . ''
+ '' . $u->info['login'] . ' выгнал из похода персонажа ' . $who . ''
);
} else {
$this->sys_chat(
- '' . $u->info['login'] . ' выгнала из похода персонажа ' . $to['login'] . ''
+ '' . $u->info['login'] . ' выгнала из похода персонажа ' . $who . ''
);
}
- header('Location: /main.php');
+
+ exit("");
}
}
@@ -2067,7 +2066,7 @@ class Dungeon
public function genObjects()
{
- global $u, $c, $code;
+ global $u;
////i:{id,name,mapPoint,action,img,type},
//'count':1,0:{0:1234,1:'Сундук',2:5,3:'',4:'test.gif',5:0,6:position,7:width,8:heigh,9:left,10:top},
//psition 0 - по центру , 1- сверху, 2- слева, 3- снизу, 4- справа
@@ -2083,74 +2082,103 @@ class Dungeon
$i = 0;
$pos = [];
while ($pl = mysql_fetch_assoc($sp)) {
- if ($pl['fix_x_y'] == 0 || ($pl['fix_x_y'] == 1 && $pl['x'] == $u->info['x']) || ($pl['fix_x_y'] == 2 && $pl['y'] == $u->info['y']) || ($pl['fix_x_y'] == 3 && $pl['x'] == $u->info['x'] && $pl['y'] == $u->info['y'])) {
- if (($pl['os1'] == 0 && $pl['os2'] == 0 && $pl['os3'] == 0 && $pl['os4'] == 0) || ($this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os1'] || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os2'] || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os3'] || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os4'])) {
- $i++;
- if (!isset($pos[$this->cord[$pl['y'] . '_' . $pl['x']]])) {
- $pos[$this->cord[$pl['y'] . '_' . $pl['x']]] = 0;
- }
- $pos[$this->cord[$pl['y'] . '_' . $pl['x']]]++;
- $r .= ',' . ($i - 1) . ':{0:' . $pl['id'] . ',1:\'' . $pl['name'] . '\',2:' . (0 + $this->cord[$pl['y'] . '_' . $pl['x']]) . ',3:\'action\',4:\'' . $pl['img'] . '\',5:' . $pl['type'] . ',6:0,7:' . $pl['w'] . ',8:' . $pl['h'] . ',9:' . $pl['left'] . ',10:' . $pl['top'] . ',11:' . $pl['date'] . '}';
- } elseif ($this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os1'] - 1 || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os2'] - 1 || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os3'] - 1 || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os4'] - 1) {
- $dt2 = explode(',', ltrim(rtrim($pl['date'], '\}'), '\{'));
- $da = [];
- $is = 0;
- while ($is < count($dt2)) {
- $dt2[$is] = explode(':', $dt2[$is]);
- $da[$dt2[$is][0]] = $dt2[$is][1];
- $is++;
- }
- if (isset($da['use'])) {
- unset($da['use']);
- } // Справа
- if (isset($da['rl2'])) {
- $da['rl2'] = -round((int)$da['rl2'] * 1.55);
- } // Слева
- if (isset($da['rl3'])) {
- $da['rl3'] = round((int)$da['rl3'] + 160);
- }
- if (isset($da['rl4'])) {
- $da['rl4'] = round((int)$da['rl4'] - 120);
- }
- $pl['date'] = str_replace('"', '', json_encode($da));
+ if (!isset($this->cord[$pl['y'] . '_' . $pl['x']])) {
+ continue;
+ }
+ if (
+ $pl['fix_x_y'] != 0 &&
+ ($pl['fix_x_y'] != 1 || $pl['x'] != $u->info['x']) &&
+ ($pl['fix_x_y'] != 2 || $pl['y'] != $u->info['y']) &&
+ ($pl['fix_x_y'] != 3 || $pl['x'] != $u->info['x'] || $pl['y'] != $u->info['y'])
+ ) {
+ continue;
+ }
- $i++;
- if (!isset($pos[$this->cord[$pl['y'] . '_' . $pl['x']]])) {
- $pos[$this->cord[$pl['y'] . '_' . $pl['x']]] = 0;
- }
- $pos[$this->cord[$pl['y'] . '_' . $pl['x']]]++;
- $r .= ',' . ($i - 1) . ':{0:' . $pl['id'] . ',1:\'' . $pl['name'] . '\',2:' . (0 + $this->cord[$pl['y'] . '_' . $pl['x']]) . ',3:\'\',4:\'' . $pl['img'] . '\',5:' . $pl['type'] . ',6:0,7:' . $pl['w'] . ',8:' . $pl['h'] . ',9:' . $pl['left'] . ',10:' . $pl['top'] . ',11:' . $pl['date'] . '}';
- } elseif ($this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os1'] + 1 || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os2'] + 1 || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os3'] + 1 || $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os4'] + 1) {
-
- $dt2 = explode(',', ltrim(rtrim($pl['date'], '\}'), '\{'));
- $da = [];
- $is = 0;
- while ($is < count($dt2)) {
- $dt2[$is] = explode(':', $dt2[$is]);
- $da[$dt2[$is][0]] = $dt2[$is][1];
- $is++;
- }
- if (isset($da['use'])) {
- unset($da['use']);
- } // Справа
- if (isset($da['rl2'])) {
- $da['rl2'] = 355 - round((int)$da['rl2'] * 0.30);
- } // Справа
- if (isset($da['rl3'])) {
- $da['rl3'] = round((int)$da['rl3'] - 160);
- }
- if (isset($da['rl4'])) {
- $da['rl4'] = round((int)$da['rl4'] + 120);
- }
- $pl['date'] = str_replace('"', '', json_encode($da));
- $i++;
- if (!isset($pos[$this->cord[$pl['y'] . '_' . $pl['x']]])) {
- $pos[$this->cord[$pl['y'] . '_' . $pl['x']]] = 0;
- }
- $pos[$this->cord[$pl['y'] . '_' . $pl['x']]]++;
- $r .= ',' . ($i - 1) . ':{0:' . $pl['id'] . ',1:\'' . $pl['name'] . '\',2:' . (0 + $this->cord[$pl['y'] . '_' . $pl['x']]) . ',3:\'\',4:\'' . $pl['img'] . '\',5:' . $pl['type'] . ',6:0,7:' . $pl['w'] . ',8:' . $pl['h'] . ',9:' . $pl['left'] . ',10:' . $pl['top'] . ',11:' . $pl['date'] . '}';
+ if (
+ ($pl['os1'] == 0 && $pl['os2'] == 0 && $pl['os3'] == 0 && $pl['os4'] == 0) ||
+ (
+ $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os1'] ||
+ $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os2'] ||
+ $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os3'] ||
+ $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os4']
+ )
+ ) {
+ $i++;
+ if (!isset($pos[$this->cord[$pl['y'] . '_' . $pl['x']]])) {
+ $pos[$this->cord[$pl['y'] . '_' . $pl['x']]] = 0;
}
+ $pos[$this->cord[$pl['y'] . '_' . $pl['x']]]++;
+ $r .= ',' . ($i - 1) . ':{0:' . $pl['id'] . ',1:\'' . $pl['name'] . '\',2:' . (0 + $this->cord[$pl['y'] . '_' . $pl['x']]) . ',3:\'action\',4:\'' . $pl['img'] . '\',5:' . $pl['type'] . ',6:0,7:' . $pl['w'] . ',8:' . $pl['h'] . ',9:' . $pl['left'] . ',10:' . $pl['top'] . ',11:' . $pl['date'] . '}';
+ } elseif (
+ $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os1'] - 1 ||
+ $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os2'] - 1 ||
+ $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os3'] - 1 ||
+ $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os4'] - 1
+ ) {
+ $dt2 = explode(',', ltrim(rtrim($pl['date'], '\}'), '\{'));
+ $da = [];
+ $is = 0;
+ while ($is < count($dt2)) {
+ $dt2[$is] = explode(':', $dt2[$is]);
+ $da[$dt2[$is][0]] = $dt2[$is][1];
+ $is++;
+ }
+ if (isset($da['use'])) {
+ unset($da['use']);
+ } // Справа
+ if (isset($da['rl2'])) {
+ $da['rl2'] = -round((int)$da['rl2'] * 1.55);
+ } // Слева
+ if (isset($da['rl3'])) {
+ $da['rl3'] = round((int)$da['rl3'] + 160);
+ }
+ if (isset($da['rl4'])) {
+ $da['rl4'] = round((int)$da['rl4'] - 120);
+ }
+ $pl['date'] = str_replace('"', '', json_encode($da));
+
+
+ $i++;
+ if (!isset($pos[$this->cord[$pl['y'] . '_' . $pl['x']]])) {
+ $pos[$this->cord[$pl['y'] . '_' . $pl['x']]] = 0;
+ }
+ $pos[$this->cord[$pl['y'] . '_' . $pl['x']]]++;
+ $r .= ',' . ($i - 1) . ':{0:' . $pl['id'] . ',1:\'' . $pl['name'] . '\',2:' . (0 + $this->cord[$pl['y'] . '_' . $pl['x']]) . ',3:\'\',4:\'' . $pl['img'] . '\',5:' . $pl['type'] . ',6:0,7:' . $pl['w'] . ',8:' . $pl['h'] . ',9:' . $pl['left'] . ',10:' . $pl['top'] . ',11:' . $pl['date'] . '}';
+ } elseif (
+ $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os1'] + 1 ||
+ $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os2'] + 1 ||
+ $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os3'] + 1 ||
+ $this->cord[$pl['y'] . '_' . $pl['x']] == $pl['os4'] + 1
+ ) {
+
+ $dt2 = explode(',', ltrim(rtrim($pl['date'], '\}'), '\{'));
+ $da = [];
+ $is = 0;
+ while ($is < count($dt2)) {
+ $dt2[$is] = explode(':', $dt2[$is]);
+ $da[$dt2[$is][0]] = $dt2[$is][1];
+ $is++;
+ }
+ if (isset($da['use'])) {
+ unset($da['use']);
+ } // Справа
+ if (isset($da['rl2'])) {
+ $da['rl2'] = 355 - round((int)$da['rl2'] * 0.30);
+ } // Справа
+ if (isset($da['rl3'])) {
+ $da['rl3'] = round((int)$da['rl3'] - 160);
+ }
+ if (isset($da['rl4'])) {
+ $da['rl4'] = round((int)$da['rl4'] + 120);
+ }
+ $pl['date'] = str_replace('"', '', json_encode($da));
+ $i++;
+ if (!isset($pos[$this->cord[$pl['y'] . '_' . $pl['x']]])) {
+ $pos[$this->cord[$pl['y'] . '_' . $pl['x']]] = 0;
+ }
+ $pos[$this->cord[$pl['y'] . '_' . $pl['x']]]++;
+ $r .= ',' . ($i - 1) . ':{0:' . $pl['id'] . ',1:\'' . $pl['name'] . '\',2:' . (0 + $this->cord[$pl['y'] . '_' . $pl['x']]) . ',3:\'\',4:\'' . $pl['img'] . '\',5:' . $pl['type'] . ',6:0,7:' . $pl['w'] . ',8:' . $pl['h'] . ',9:' . $pl['left'] . ',10:' . $pl['top'] . ',11:' . $pl['date'] . '}';
}
}
return 'count:' . $i . $r;
@@ -2158,15 +2186,24 @@ class Dungeon
public function genUsers()
{
- global $u, $c, $code;
+ global $u;
////i:{id,login,mapPoint,sex,obraz,type,users_p},
//'count':1,0:{0:1015,1:'Test1',2:5,3:0,4:'1',5:'user',6:1},
$r = '';
- $whr = [1 => ' ((`u`.`x` <= ' . ($u->info['x'] + 2) . ' && `u`.`x` >= ' . ($u->info['x'] - 2) . ') && (`u`.`y` >= ' . $u->info['y'] . ' && `u`.`y` <= ' . ($u->info['y'] + 4) . ')) ', //прямо
- 3 => ' ((`u`.`x` <= ' . ($u->info['x'] + 2) . ' && `u`.`x` >= ' . ($u->info['x'] - 2) . ') && (`u`.`y` <= ' . $u->info['y'] . ' && `u`.`y` >= ' . ($u->info['y'] - 4) . ')) ', //вниз
- 2 => ' ((`u`.`x` <= ' . $u->info['x'] . ' && `u`.`x` >= ' . ($u->info['x'] - 4) . ') && (`u`.`y` <= ' . ($u->info['y'] + 2) . ' && `u`.`y` >= ' . ($u->info['y'] - 2) . ')) ', //лево
- 4 => ' ((`u`.`x` >= ' . $u->info['x'] . ' && `u`.`x` <= ' . ($u->info['x'] + 4) . ') && (`u`.`y` <= ' . ($u->info['y'] + 2) . ' && `u`.`y` >= ' . ($u->info['y'] - 2) . ')) ', //право
+ $whr = [
+ 1 => ' ((x <= ' . ($u->info['x'] + 2) . ' && x >= ' . ($u->info['x'] - 2) . ') && (y >= ' . $u->info['y'] . ' && y <= ' . ($u->info['y'] + 4) . ')) ', //прямо
+ 2 => ' ((x <= ' . $u->info['x'] . ' && x >= ' . ($u->info['x'] - 4) . ') && (y <= ' . ($u->info['y'] + 2) . ' && y >= ' . ($u->info['y'] - 2) . ')) ', //лево
+ 3 => ' ((x <= ' . ($u->info['x'] + 2) . ' && x >= ' . ($u->info['x'] - 2) . ') && (y <= ' . $u->info['y'] . ' && y >= ' . ($u->info['y'] - 4) . ')) ', //вниз
+ 4 => ' ((x >= ' . $u->info['x'] . ' && x <= ' . ($u->info['x'] + 4) . ') && (y <= ' . ($u->info['y'] + 2) . ' && y >= ' . ($u->info['y'] - 2) . ')) ', //право
];
+
+ $whrVals = [ // x <= ? && x >= ? && y <= ? && y >= ?
+ 1 => [$u->info['x'] + 2, $u->info['x'] - 2, $u->info['y'] + 4, $u->info['y'],], // прямо x< x> y< y>
+ 2 => [$u->info['x'], $u->info['x'] - 4, $u->info['y'] + 2, $u->info['y'] - 2,], // лево x< x> y< y>
+ 3 => [$u->info['x'] + 2, $u->info['x'] - 2, $u->info['y'], $u->info['y'] - 4,], // низ x< x> y< y>
+ 4 => [$u->info['x'] + 4, $u->info['x'], $u->info['y'] + 2, $u->info['y'] - 2,], // право x< x> y< y>
+ ];
+
//
$tmsu = mysql_fetch_assoc(
mysql_query('SELECT * FROM `katok_now` WHERE `clone` = "' . $u->info['id'] . '" LIMIT 1')
@@ -2266,10 +2303,19 @@ class Dungeon
}
}
- $sp = mysql_query(
- 'SELECT `u`.*,`st`.* FROM `dungeon_bots` AS `u` LEFT JOIN `test_bot` AS `st` ON (`u`.`id_bot` = `st`.`id`) WHERE `u`.`dn` = "' . $u->info['dnow'] . '" AND ' . $whr[$this->gs] . ' AND `u`.`delete` = "0" LIMIT 50'
- );
- while ($pl = mysql_fetch_assoc($sp)) {
+
+ $botsArr = Db::getRows('select * from dungeon_bots left join test_bot on dungeon_bots.id_bot = test_bot.id where dn = ? and x <= ? and x >= ? and y <= ? and y >= ? limit 50',[
+ $u->info['dnow'], $whrVals[$this->gs][0], $whrVals[$this->gs][1], $whrVals[$this->gs][2], $whrVals[$this->gs][3],
+ ]);
+
+ foreach ($botsArr as $pl) {
+
+// }
+//
+// $sp = mysql_query(
+// 'SELECT `u`.*,`st`.* FROM `dungeon_bots` AS `u` LEFT JOIN `test_bot` AS `st` ON (`u`.`id_bot` = `st`.`id`) WHERE `u`.`dn` = "' . $u->info['dnow'] . '" AND ' . $whr[$this->gs] . ' AND `u`.`delete` = "0" LIMIT 50'
+// );
+// while ($pl = mysql_fetch_assoc($sp)) {
$i++;
if (!isset($pos[$this->cord[$pl['y'] . '_' . $pl['x']]])) {
$pos[$this->cord[$pl['y'] . '_' . $pl['x']]] = 0;
diff --git a/modules_data/location/dungeon.php b/modules_data/location/dungeon.php
index 57855f34..a871d583 100644
--- a/modules_data/location/dungeon.php
+++ b/modules_data/location/dungeon.php
@@ -1,48 +1,27 @@
- let elem = document.getElementById('se-pre-con');
- elem.parentNode.removeChild(elem);
-
- ";
+echo "";
+
if (!defined('GAME')) {
die();
}
-
if ($u->room['file'] != 'dungeon') {
return;
}
-$pd = [1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, //передняя стенка, в 2-х шагах
- 10 => 0, 11 => 0, 12 => 0, 13 => 0, 14 => 0, 15 => 0, 16 => 0, 17 => 0, 18 => 0, 19 => 0, 20 => 0, 21 => 0, 22 => 0, 23 => 0, /* Растояние: 1 шаг */
- 24 => 0, //стена прямо слева от персонажа (1)
- 25 => 0, //стена прямо справа от персонажа (1)
- 26 => 0, //стена прямо перед персонажем (1)
- 27 => 0, //стена слева от персонажа (1)
- 28 => 0, //стена справа от персонажа (1)
-];
-
-if (isset($_POST['go_to_admin']) && $u->info['admin'] == 1 && $u->info['login'] == 'Crowley') {
- mysql_query('UPDATE `stats` SET `x` = "' . round((int)$_POST['g__x']) . '", `y` = "' . round((int)$_POST['g__y']) . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1');
- if ($_POST['g__restorebot']) {
- mysql_query('UPDATE `dungeon_bots` SET `delete` = "0" WHERE `dn` = "' . $u->info['dnow'] . '" AND `delete` = 1 LIMIT 50');
- }
- header('Location: /main.php');
-}
if (isset($_GET['back'])) {
- $dp = mysql_fetch_array(mysql_query('SELECT * FROM `dungeon_now` WHERE `id` = "' . $u->info['dnow'] . '" LIMIT 1'));
- $dp = mysql_fetch_array(mysql_query('SELECT * FROM `dungeon_map` WHERE `id_dng` = "' . $dp['id2'] . '" AND `x` = "' . $u->info['x'] . '" AND `y` ="' . $u->info['y'] . '" LIMIT 1'));
- if ($dp['file'] != '0') {
+ $dp = Db::getValue('select file from dungeon_map where id_dng = (select id2 from dungeon_now where id = ?) and x = ? and y = ?', [$u->info['dnow'], $u->info['x'], $u->info['y']]);
+ if ($dp != '0') {
$file = explode('=', $dp['file']);
if (isset($file[1])) {
if ($file[3] < 1 || $file[3] > 4) {
$file[3] = 1;
}
- mysql_query('UPDATE `stats` SET `x` = "' . $file[1] . '",`y` = "' . $file[2] . '",`s` = "' . $file[3] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1');
+ Db::sql('update stats set x = ?, y = ?, s = ? where id = ?', [$file[1], $file[2], $file[3], $u->info['id']]);
$u->info['x'] = $file[1];
$u->info['y'] = $file[2];
$u->info['s'] = $file[3];
@@ -57,8 +36,7 @@ if (!isset($d->info['id'])) {
$_GET['exitd'] = true;
}
-$dies = mysql_fetch_array(mysql_query('SELECT COUNT(`id`) FROM `dungeon_actions` WHERE `uid` = "' . $u->info['id'] . '" AND `dn` = "' . $u->info['dnow'] . '" AND `vars` = "die" LIMIT 1'));
-$dies = $dies[0];
+$dies = Db::getValue('select count(id) from dungeon_actions where uid = ? and dn = ? and vars = ?', [$u->info['id'], $u->info['dnow'], 'die']);
if ($dies >= 3) {
$_GET['exitd'] = true;
@@ -71,11 +49,11 @@ if (!isset($d->point['id'])) {
}
if (isset($_GET['new_leader'])) {
- echo $d->n_lead($_GET['new_leader'], $u->info['id']);
+ $d->n_lead($_GET['new_leader'], $u->info['id']);
}
if (isset($_GET['go_from_psh'])) {
- echo $d->go_to_hell($_GET['go_from_psh'], $u->info['id']);
+ $d->go_to_hell($_GET['go_from_psh'], $u->info['id']);
}
@@ -209,7 +187,11 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
bott = 0;
if (stor == 1) {
info['dnow'] . '" AND `delete` = "0" AND `x` = "' . ($u->info['x']) . '" AND `y` = "' . ($u->info['y'] + 1) . '" LIMIT 1'));
+ $bottem = mysql_fetch_assoc(
+ mysql_query(
+ 'SELECT `id2` FROM `dungeon_bots` WHERE `dn` = "' . $u->info['dnow'] . '" AND `delete` = "0" AND `x` = "' . ($u->info['x']) . '" AND `y` = "' . ($u->info['y'] + 1) . '" LIMIT 1'
+ )
+ );
if (isset($bottem['id2']))
{
?> bott = = $bottem['id2'];?>;point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
?>
} else if (stor == 2) {
info['dnow'] . '" AND `delete` = "0" AND `x` = "' . ($u->info['x'] - 1) . '" AND `y` = "' . ($u->info['y']) . '" LIMIT 1'));
+ $bottem = mysql_fetch_assoc(
+ mysql_query(
+ 'SELECT `id2` FROM `dungeon_bots` WHERE `dn` = "' . $u->info['dnow'] . '" AND `delete` = "0" AND `x` = "' . ($u->info['x'] - 1) . '" AND `y` = "' . ($u->info['y']) . '" LIMIT 1'
+ )
+ );
if (isset($bottem['id2']))
{
?> bott = = $bottem['id2'];?>;point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
?>
} else if (stor == 3) {
info['dnow'] . '" AND `delete` = "0" AND `x` = "' . ($u->info['x']) . '" AND `y` = "' . ($u->info['y'] - 1) . '" LIMIT 1'));
+ $bottem = mysql_fetch_assoc(
+ mysql_query(
+ 'SELECT `id2` FROM `dungeon_bots` WHERE `dn` = "' . $u->info['dnow'] . '" AND `delete` = "0" AND `x` = "' . ($u->info['x']) . '" AND `y` = "' . ($u->info['y'] - 1) . '" LIMIT 1'
+ )
+ );
if (isset($bottem['id2']))
{
?> bott = = $bottem['id2'];?>;point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
?>
} else if (stor == 4) {
info['dnow'] . '" AND `delete` = "0" AND `x` = "' . ($u->info['x'] + 1) . '" AND `y` = "' . ($u->info['y']) . '" LIMIT 1'));
+ $bottem = mysql_fetch_assoc(
+ mysql_query(
+ 'SELECT `id2` FROM `dungeon_bots` WHERE `dn` = "' . $u->info['dnow'] . '" AND `delete` = "0" AND `x` = "' . ($u->info['x'] + 1) . '" AND `y` = "' . ($u->info['y']) . '" LIMIT 1'
+ )
+ );
if (isset($bottem['id2']))
{
?> bott = = $bottem['id2'];?>;point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
}
} else if (event.which == 32 || event.which == 90) {
itemtake = 0;
- info['dnow'] . '" AND `ish`.`take` = "0" AND `ish`.`delete` = "0" AND ( `ish`.`onlyfor` = "0" OR `ish`.`onlyfor` = "' . $u->info['id'] . '" ) AND `ish`.`x` = "' . $u->info['x'] . '" AND `ish`.`y` = "' . $u->info['y'] . '" LIMIT 1'));
+ info['dnow'] . '" AND `ish`.`take` = "0" AND `ish`.`delete` = "0" AND ( `ish`.`onlyfor` = "0" OR `ish`.`onlyfor` = "' . $u->info['id'] . '" ) AND `ish`.`x` = "' . $u->info['x'] . '" AND `ish`.`y` = "' . $u->info['y'] . '" LIMIT 1'
+ )
+ );
if (isset($sp['id']))
{ ?>
itemtake = = $sp['id'];?>;
@@ -330,21 +328,21 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
var objects = {};
//i:{id,login,mapPoint,sex,obraz,type,users_p},
- var users = {= $d->genUsers(); ?>};
+ const users = {= $d->genUsers(); ?>};
var objs = {= $d->genObjects(); ?>};
var items = {};
var actions = {};
var dsee = = 0 + $d->gs; ?>;
var mapp = {
- 1: '0_0f', 2: '0_0f', 3: '0_0f', 4: '1_1f', 5: '1_1f', 6: '1_1f'
- , 7: '2_1f', 8: '2_1f', 9: '2_1f'
- , 11: '3_1l', 12: '3_1f', 13: '3_1r'
+ 1: '0_0f', 2: '0_0f', 3: '0_0f', 4: '1_1f',
+ 5: '1_1f', 6: '1_1f', 7: '2_1f', 8: '2_1f',
+ 9: '2_1f', 11: '3_1l', 12: '3_1f', 13: '3_1r'
}
var zmap = {5: 894, 8: 0, 12: 0}
var zfloor0 = {1: '', 2: '', 3: '', 4: '', 5: ''};
function genMap() {
- var i = 0, m = false, mz = false;
+ let i = 0, m = false, mz = false;
while (i < users['count']) {
if (users[i] != undefined) {
mz = mapp[users[i][2]];
@@ -355,7 +353,10 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
}
i++;
}
- var i = 0, m = false, mz = false;
+
+ i = 0;
+ m = false;
+ mz = false;
while (i < objs['count']) {
if (objs[i] != undefined) {
mz = mapp[objs[i][2]];
@@ -369,7 +370,7 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
}
i++;
}
- var i = 5;
+ i = 5;
while (i >= 1) {
if (zfloor0[i] != '') {
document.getElementById('Floor0').innerHTML += zfloor0[i];
@@ -691,51 +692,16 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
$tmGol = $u->info['timeGo'] - $u->info['timeGoL']; //сколько секунд идти всего
echo 'var tgo = ' . ($tmGo * 10) . '; var tgol = ' . ($tmGol * 10) . ';'; ?>
-
-