mirror of
https://github.com/Project-Redacted/Gayme.git
synced 2025-05-24 11:54:53 +00:00
Fix Crash on Pathfinding error
This commit is contained in:
parent
41a0ec665b
commit
760b29a761
4 changed files with 15 additions and 13 deletions
|
@ -23,17 +23,20 @@ class PathFinding:
|
|||
queue = deque([start])
|
||||
visited = {start: None}
|
||||
|
||||
while queue:
|
||||
cur_node = queue.popleft()
|
||||
if cur_node == goal:
|
||||
break
|
||||
next_nodes = graph[cur_node]
|
||||
try:
|
||||
while queue:
|
||||
cur_node = queue.popleft()
|
||||
if cur_node == goal:
|
||||
break
|
||||
next_nodes = graph[cur_node]
|
||||
|
||||
for next_node in next_nodes:
|
||||
if next_node not in visited and next_node not in self.game.object_handler.npc_positions:
|
||||
queue.append(next_node)
|
||||
visited[next_node] = cur_node
|
||||
return visited
|
||||
for next_node in next_nodes:
|
||||
if next_node not in visited and next_node not in self.game.object_handler.npc_positions:
|
||||
queue.append(next_node)
|
||||
visited[next_node] = cur_node
|
||||
return visited
|
||||
except KeyError:
|
||||
return visited
|
||||
|
||||
def get_next_nodes(self, x, y):
|
||||
return [(x + dx, y + dy) for dx, dy in self.ways if (x + dx, y + dy) not in self.game.map.world_map]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue