Limit path finding max complexity
This commit is contained in:
parent
8c6d5a0f5c
commit
18a37393c5
|
@ -540,6 +540,8 @@ std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> Map::findPath(const
|
|||
}
|
||||
};
|
||||
|
||||
const uint MAX_COMPLEXITY = 100000;
|
||||
|
||||
std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> ret;
|
||||
std::vector<Otc::Direction>& dirs = std::get<0>(ret);
|
||||
Otc::PathFindResult& result = std::get<1>(ret);
|
||||
|
@ -575,6 +577,11 @@ std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> Map::findPath(const
|
|||
break;
|
||||
}
|
||||
|
||||
if(nodes.size() > MAX_COMPLEXITY) {
|
||||
result = Otc::PathFindResultTooFar;
|
||||
break;
|
||||
}
|
||||
|
||||
// path found
|
||||
if(currentNode->pos == goalPos && (!foundNode || currentNode->cost < foundNode->cost))
|
||||
foundNode = currentNode;
|
||||
|
|
|
@ -714,7 +714,7 @@ bool UITextEdit::onKeyPress(uchar keyCode, int keyboardModifiers, int autoRepeat
|
|||
if(UIWidgetPtr parent = getParent())
|
||||
parent->focusPreviousChild(Fw::KeyboardFocusReason);
|
||||
return true;
|
||||
} else if(keyCode == Fw::KeyRight || keyCode == Fw::KeyLeft || keyCode == Fw::KeyUp || keyCode == Fw::KeyDown) {
|
||||
} else if(keyCode == Fw::KeyRight || keyCode == Fw::KeyLeft) {
|
||||
|
||||
int oldCursorPos = m_cursorPos;
|
||||
|
||||
|
@ -722,10 +722,6 @@ bool UITextEdit::onKeyPress(uchar keyCode, int keyboardModifiers, int autoRepeat
|
|||
moveCursorHorizontally(true);
|
||||
else if(keyCode == Fw::KeyLeft) // move cursor left
|
||||
moveCursorHorizontally(false);
|
||||
else if(keyCode == Fw::KeyUp) // move cursor right
|
||||
moveCursorVertically(true);
|
||||
else if(keyCode == Fw::KeyDown) // move cursor left
|
||||
moveCursorVertically(false);
|
||||
|
||||
if(m_shiftNavigation)
|
||||
clearSelection();
|
||||
|
|
Loading…
Reference in New Issue