Skip to content

Commit

Permalink
don't traverse disabled blocks in random mode
Browse files Browse the repository at this point in the history
fixes #167
  • Loading branch information
Novakasa committed Nov 18, 2023
1 parent b346051 commit 710d620
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions brickrail-gui/layout/route/layout_node.gd
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func calculate_routes(reversing_behavior, train_id=null):
current_node.collect_edges()
for neighbour_id in current_node.edges:
var edge = current_node.edges[neighbour_id]

if LayoutInfo.nodes[neighbour_id].type=="block":
if LayoutInfo.nodes[neighbour_id].obj.disable_train:
continue

if train_id != null:
var edge_locked = edge.get_locked()
Expand Down
4 changes: 3 additions & 1 deletion brickrail-gui/layout/train/layout_train.gd
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func is_end_of_leg():
return route.get_current_leg().is_complete()

func _on_LayoutInfo_random_targets_set(_random_targets):
if LayoutInfo.random_targets and route==null and random_targets:
if LayoutInfo.random_targets and route==null and random_targets and not block.disable_train:
find_random_route(false)

func update_control_ble_train():
Expand Down Expand Up @@ -227,6 +227,8 @@ func get_all_valid_routes(no_locked=true, target_facing=null):
continue
if not LayoutInfo.nodes[node_id].obj.can_stop:
continue
if LayoutInfo.nodes[node_id].obj.disable_train:
continue
if target_facing != null and target_facing != LayoutInfo.nodes[node_id].facing:
continue
if not LayoutInfo.nodes[node_id].obj.random_target:
Expand Down

0 comments on commit 710d620

Please sign in to comment.