Skip to content

Commit b2bfd75

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

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

core/AI/pathfind.ai.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function canGoTo($from = [], $direction = 0, $checkFlow = false, $step =
111111
return true;
112112
}
113113

114-
$stepT = $this->getFlowNodeFrom($from, $direction);
114+
$stepT = $this->getFlowNodeFrom($direction, $from);
115115

116116
if ($stepT != $step) {
117117
return false;
@@ -320,7 +320,7 @@ public function getPathFromFlow($from = null, $steps = null) {
320320
}
321321

322322
$dir = $this->getDirection($from, $this->destination, true, $steps);
323-
$next = $this->getFlowNodeFrom($from, $dir);
323+
$next = $this->getFlowNodeFrom($dir, $from);
324324

325325
if ($next == $steps) {
326326
$nDir = $this->getNodeDir($from, $dir);
@@ -520,7 +520,7 @@ public function getAroundNodes($from = []) {
520520
];
521521
}
522522

523-
public function getFlowNodeFrom($from = [], $direction) {
523+
public function getFlowNodeFrom($direction, $from = []) {
524524
switch ($direction) {
525525
case self::DIR_NORTH:
526526
return (isset($this->mapFlow[($from[1] - 1)][($from[0])]) ? $this->mapFlow[($from[1] - 1)][($from[0])] : -1);
@@ -608,14 +608,14 @@ public function getFlowNodeFrom($from = [], $direction) {
608608

609609
public function getAroundFlowNodes($from = []) {
610610
$ret = [
611-
self::DIR_NORTH => [0 => ($from[0]), 1 => ($from[1] - 1), 3 => $this->getFlowNodeFrom($from, self::DIR_NORTH)],
612-
self::DIR_NORTHEAST => [0 => ($from[0] + 1), 1 => ($from[1] - 1), 3 => $this->getFlowNodeFrom($from, self::DIR_NORTHEAST)],
613-
self::DIR_EAST => [0 => ($from[0] + 1), 1 => ($from[1]), 3 => $this->getFlowNodeFrom($from, self::DIR_EAST)],
614-
self::DIR_SOUTHEAST => [0 => ($from[0] + 1), 1 => ($from[1] + 1), 3 => $this->getFlowNodeFrom($from, self::DIR_SOUTHEAST)],
615-
self::DIR_SOUTH => [0 => ($from[0]), 1 => ($from[1] + 1), 3 => $this->getFlowNodeFrom($from, self::DIR_SOUTH)],
616-
self::DIR_SOUTHWEST => [0 => ($from[0] - 1), 1 => ($from[1] + 1), 3 => $this->getFlowNodeFrom($from, self::DIR_SOUTHWEST)],
617-
self::DIR_WEST => [0 => ($from[0] - 1), 1 => ($from[1]), 3 => $this->getFlowNodeFrom($from, self::DIR_WEST)],
618-
self::DIR_NORTHWEST => [0 => ($from[0] - 1), 1 => ($from[1] - 1), 3 => $this->getFlowNodeFrom($from, self::DIR_NORTHWEST)],
611+
self::DIR_NORTH => [0 => ($from[0]), 1 => ($from[1] - 1), 3 => $this->getFlowNodeFrom(self::DIR_NORTH, $from)],
612+
self::DIR_NORTHEAST => [0 => ($from[0] + 1), 1 => ($from[1] - 1), 3 => $this->getFlowNodeFrom(self::DIR_NORTHEAST, $from)],
613+
self::DIR_EAST => [0 => ($from[0] + 1), 1 => ($from[1]), 3 => $this->getFlowNodeFrom(self::DIR_EAST, $from)],
614+
self::DIR_SOUTHEAST => [0 => ($from[0] + 1), 1 => ($from[1] + 1), 3 => $this->getFlowNodeFrom(self::DIR_SOUTHEAST, $from)],
615+
self::DIR_SOUTH => [0 => ($from[0]), 1 => ($from[1] + 1), 3 => $this->getFlowNodeFrom(self::DIR_SOUTH, $from)],
616+
self::DIR_SOUTHWEST => [0 => ($from[0] - 1), 1 => ($from[1] + 1), 3 => $this->getFlowNodeFrom(self::DIR_SOUTHWEST, $from)],
617+
self::DIR_WEST => [0 => ($from[0] - 1), 1 => ($from[1]), 3 => $this->getFlowNodeFrom(self::DIR_WEST, $from)],
618+
self::DIR_NORTHWEST => [0 => ($from[0] - 1), 1 => ($from[1] - 1), 3 => $this->getFlowNodeFrom(self::DIR_NORTHWEST, $from)],
619619
];
620620

621621
foreach ($ret as $nk => $node) {

0 commit comments

Comments
 (0)