From 5f08c1b4c66b873b9a8df43f5dcaad0d14d72583 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 5 Jul 2023 00:58:54 +0200 Subject: Check withdrawal using own supply lines only! ... and more burned CPU cycles. --- rules.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rules.js b/rules.js index eb5bc6b..316d2ac 100644 --- a/rules.js +++ b/rules.js @@ -1956,13 +1956,15 @@ function unit_has_supply_line(who) { function can_unit_withdraw(who) { let result = false if (unit_has_supply_line(who)) { + let ssrc = unit_supply_source(who) let sline = unit_supply_line(who) let sdist = unit_supply_distance(who) let from = unit_hex(who) + search_own_supply_line(from, ssrc, sline, sdist) for_each_adjacent_hex(from, to => { let side = to_side_id(from, to) if (side_limit[side] > 0 && !has_enemy_unit(to)) - if (sline[side] && sdist[to] <= sdist[from]) + if (own_supply_line[side] && sdist[to] <= sdist[from]) result = true }) } @@ -1972,13 +1974,15 @@ function can_unit_withdraw(who) { function can_unit_disengage_and_withdraw(who) { let result = false if (unit_has_supply_line(who)) { + let ssrc = unit_supply_source(who) let sline = unit_supply_line(who) let sdist = unit_supply_distance(who) let from = unit_hex(who) + search_own_supply_line(from, ssrc, sline, sdist) for_each_adjacent_hex(from, to => { let side = to_side_id(from, to) if (side_limit[side] > 0 && !is_enemy_hexside(side) && !has_undisrupted_enemy_unit(to)) - if (sline[side] && sdist[to] <= sdist[from]) + if (own_supply_line[side] && sdist[to] <= sdist[from]) result = true }) } -- cgit v1.2.3