diff options
-rw-r--r-- | rules.js | 26 |
1 files changed, 8 insertions, 18 deletions
@@ -1130,7 +1130,7 @@ function ind(d, msg, here, ...extra) { var supply_defender, supply_defender_sides, supply_friendly, supply_enemy, supply_net, supply_line, supply_fortress_enemy var supply_visited = new Array(hexcount).fill(0) -var supply_src = new Array(hexcount).fill(0) +var supply_src = 0 var trace_total @@ -1164,7 +1164,7 @@ function trace_supply_highway(here, d) { ind(d, "> highway", here) // TODO: hoist to call sites to avoid function call overhead - if (supply_src[here]) { + if (supply_src === here) { ind(d, "! source highway", here) return true } @@ -1207,11 +1207,8 @@ function trace_supply_highway(here, d) { supply_visited[here] = 0 - if (has_supply) { + if (has_supply) supply_net[here] = 1 - if (supply_enemy[here] <= 1) - supply_src[here] = 1 - } return has_supply } @@ -1220,7 +1217,7 @@ function trace_supply_chain(here, d, n, range) { trace_total++ ind(d, "> chain", here, n, range) - if (supply_src[here]) { + if (supply_src === here) { ind(d, "! source chain", here) return true } @@ -1282,23 +1279,18 @@ function trace_supply_chain(here, d, n, range) { supply_visited[here] = 0 - if (has_supply) { + if (has_supply) supply_net[here] = 1 - // undisrupted units can chain supply - if (supply_friendly[here] > 1 && supply_enemy[here] <= 1) - supply_src[here] = 1 - } return has_supply } function trace_supply_network(start, ss) { supply_visited.fill(0) - supply_src.fill(0) supply_net.fill(0) supply_line.fill(0) - supply_src[start] = 1 + supply_src = start supply_net[start] = 1 trace_total = 0 @@ -1311,11 +1303,10 @@ function trace_supply_network(start, ss) { function trace_fortress_network(fortress, ss) { supply_visited.fill(0) - supply_src.fill(0) supply_net.fill(0) supply_line.fill(0) - supply_src[fortress] = 1 + supply_src = fortress supply_net[fortress] = 1 trace_total = 0 @@ -1358,8 +1349,7 @@ function init_trace_supply_to_base_or_fortress() { function can_trace_supply_to_base_or_fortress(base, from) { supply_visited.fill(0) - supply_src.fill(0) - supply_src[base] = 1 + supply_src = base return trace_supply_chain(from, 0, 0, 3) } |