Skip to content

Commit d30aed0

Browse files
committed
PHP7.4-Compatibility: FlowPath::getNodeFrom() putting optional parameter after the required one
1 parent b2bfd75 commit d30aed0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

core/AI/pathfind.ai.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private function getBestDirection($from = [], $direction = 0, $checkFlow = false
105105

106106
public function canGoTo($from = [], $direction = 0, $checkFlow = false, $step = null) {
107107
if (!$checkFlow) {
108-
if ($this->getNodeFrom($from, $direction) === FlowPath::TYPE_WALL) {
108+
if ($this->getNodeFrom($direction, $from) === FlowPath::TYPE_WALL) {
109109
return false;
110110
}
111111
return true;
@@ -422,7 +422,7 @@ public function getDestination() {
422422
}
423423
}
424424

425-
public function getNodeFrom($from = [], $direction) {
425+
public function getNodeFrom($direction, $from = []) {
426426
switch ($direction) {
427427
case self::DIR_NORTH:
428428
if (!isset($this->map[($from[1] - 1)]) || !isset($this->map[($from[1] - 1)][($from[0])])) {
@@ -509,14 +509,14 @@ public function getNodeFrom($from = [], $direction) {
509509

510510
public function getAroundNodes($from = []) {
511511
return [
512-
self::DIR_NORTH => [0 => ($from[0]), 1 => ($from[1] - 1), 3 => $this->getNodeFrom($from, self::DIR_NORTH)],
513-
self::DIR_NORTHEAST => [0 => ($from[0] + 1), 1 => ($from[1] - 1), 3 => $this->getNodeFrom($from, self::DIR_NORTHEAST)],
514-
self::DIR_EAST => [0 => ($from[0] + 1), 1 => ($from[1]), 3 => $this->getNodeFrom($from, self::DIR_EAST)],
515-
self::DIR_SOUTHEAST => [0 => ($from[0] + 1), 1 => ($from[1] + 1), 3 => $this->getNodeFrom($from, self::DIR_SOUTHEAST)],
516-
self::DIR_SOUTH => [0 => ($from[0]), 1 => ($from[1] + 1), 3 => $this->getNodeFrom($from, self::DIR_SOUTH)],
517-
self::DIR_SOUTHWEST => [0 => ($from[0] - 1), 1 => ($from[1] + 1), 3 => $this->getNodeFrom($from, self::DIR_SOUTHWEST)],
518-
self::DIR_WEST => [0 => ($from[0] - 1), 1 => ($from[1]), 3 => $this->getNodeFrom($from, self::DIR_WEST)],
519-
self::DIR_NORTHWEST => [0 => ($from[0] - 1), 1 => ($from[1] - 1), 3 => $this->getNodeFrom($from, self::DIR_NORTHWEST)],
512+
self::DIR_NORTH => [0 => ($from[0]), 1 => ($from[1] - 1), 3 => $this->getNodeFrom(self::DIR_NORTH, $from)],
513+
self::DIR_NORTHEAST => [0 => ($from[0] + 1), 1 => ($from[1] - 1), 3 => $this->getNodeFrom(self::DIR_NORTHEAST), $from],
514+
self::DIR_EAST => [0 => ($from[0] + 1), 1 => ($from[1]), 3 => $this->getNodeFrom(self::DIR_EAST), $from],
515+
self::DIR_SOUTHEAST => [0 => ($from[0] + 1), 1 => ($from[1] + 1), 3 => $this->getNodeFrom( self::DIR_SOUTHEAST), $from],
516+
self::DIR_SOUTH => [0 => ($from[0]), 1 => ($from[1] + 1), 3 => $this->getNodeFrom(self::DIR_SOUTH), $from],
517+
self::DIR_SOUTHWEST => [0 => ($from[0] - 1), 1 => ($from[1] + 1), 3 => $this->getNodeFrom(self::DIR_SOUTHWEST), $from],
518+
self::DIR_WEST => [0 => ($from[0] - 1), 1 => ($from[1]), 3 => $this->getNodeFrom(self::DIR_WEST), $from],
519+
self::DIR_NORTHWEST => [0 => ($from[0] - 1), 1 => ($from[1] - 1), 3 => $this->getNodeFrom(self::DIR_NORTHWEST), $from],
520520
];
521521
}
522522

0 commit comments

Comments
 (0)