summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-07-05 00:58:54 +0200
committerTor Andersson <tor@ccxvii.net>2023-07-05 00:58:54 +0200
commit5f08c1b4c66b873b9a8df43f5dcaad0d14d72583 (patch)
tree3f55cf68ba557ad2c197a4a74ca5b2a65d4e1613
parent327552d8a5518b60d66d08954256148e98a14fdf (diff)
downloadrommel-in-the-desert-5f08c1b4c66b873b9a8df43f5dcaad0d14d72583.tar.gz
Check withdrawal using own supply lines only!
... and more burned CPU cycles.
-rw-r--r--rules.js8
1 files 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
})
}