diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-01-03 18:06:07 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-01-03 23:58:59 +0100 |
commit | fb54e6b4b0df7b90ffd68124400fefda0af89d09 (patch) | |
tree | dfa2131a4d026a1acddd601e2efed46a54365a6b /rules.js | |
parent | 165421013f25743df1b8ac52a8ca2c5c668fc870 (diff) | |
download | rommel-in-the-desert-fb54e6b4b0df7b90ffd68124400fefda0af89d09.tar.gz |
Fix supply search optimization.
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -1361,9 +1361,18 @@ function trace_unit_supply_line(path, here, here_move, ssrc) { if (next_move === TRACE_ABORT) continue - // reached supply source, or reached supplied highway (that we searched before) - /* if (next === ssrc) -- fallback without short cut in case the optimization below is wrong... */ - if (next === ssrc || (hex_road[next] === HIGHWAY && supply_net[next] === 2)) { + let reached = (next === ssrc) + if (!reached) { + // Stop searching if we reach a supplied highway, + // but only if we can't continue by trail or track. + // Example: Tobruk - EL Adem - Sidi Rezegh - Ft. Capuzzo + if (hex_road[next] === HIGHWAY && supply_net[next] === 2) + if (next_move === BACK_HIGHWAY_3 || next_move === BACK_STOP) + reached = true + } + + // reached supply source + if (reached) { for (let x of path) supply_line[x] = 2 supply_line[side] = 2 |