diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-07-05 00:58:54 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-07-05 00:58:54 +0200 |
commit | 5f08c1b4c66b873b9a8df43f5dcaad0d14d72583 (patch) | |
tree | 3f55cf68ba557ad2c197a4a74ca5b2a65d4e1613 | |
parent | 327552d8a5518b60d66d08954256148e98a14fdf (diff) | |
download | rommel-in-the-desert-5f08c1b4c66b873b9a8df43f5dcaad0d14d72583.tar.gz |
Check withdrawal using own supply lines only!
... and more burned CPU cycles.
-rw-r--r-- | rules.js | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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 }) } |