Custom routing metric for links

A link's routing metric could only be one of four presets (Prefer,
Normal, Avoid, Backup only). Links now also get a Custom option, closer
to how real networks tune IGP metrics:

- Multiplier mode scales the distance cost, (km + 60) × 0.1 to 100.
- Cost mode sets an exact cost, 1 to 65535 like an OSPF metric.

The preset buttons stay plain. Picking Custom explains how a link's cost
is worked out and lists what each preset comes to on that link. Choosing
Custom starts from the current preset and switching modes keeps the
effective cost, so nothing moves until the player changes the value.
Like the presets, it applies to every link between the two cities.

The cost formula lives in one helper, linkW(), used by compute() and the
traceroute paths. Custom links store mk/mv, which sanitize() repairs and
clamps; old saves load unchanged. The link panel skips its daily
re-render while the number field has focus, and Enter applies the value.

Tests cover routing equivalence with the presets, rerouting by cost,
mode switching, input clamping, saves, and the panel at desktop and
phone width. French, Italian and Portuguese for the new strings.
Perf on the big network: no change beyond noise, routing identical to
main.
This commit is contained in:
Marvin 2026-10-26 20:55:12 +01:00
parent 729d4d303d
commit 8a25ebdb95
6 changed files with 161 additions and 10 deletions

View file

@ -1603,7 +1603,6 @@
"Going to customers in":"Diretto ai clienti a",
"Biggest feeder: {egress} in {city}. Set it to “Backup only”, give the customers a closer egress (peering, a cache, local transit), or raise this link's metric.":"Fonte principale: {egress} a {city}. Impostala su “Solo backup”, dai ai clienti un’uscita più vicina (peering, una cache, transit locale) o alza la metrica di questo link.",
"Routing metric":"Metrica di routing",
"Your routers pick the lowest-cost path. Raise the metric to push traffic onto other paths. “Backup only” keeps it idle unless nothing else works. Applies to every link between these two cities.":"I tuoi router scelgono il percorso a costo minore. Alza la metrica per spingere il traffico su altri percorsi. “Solo backup” lo lascia a riposo finché il resto funziona. Vale per tutti i link tra queste due città.",
"Behind the Great Firewall":"Dietro il Great Firewall",
"Mainland China plays by its own rules. {list} and other foreign services are blocked here, so users mostly reach Chinese networks. Traffic crossing the border loses about {pct} to filtering and congestion, unless it rides a premium route: CN-Too transit or a premium cross-border circuit (both sold only in Hong Kong), or a PNI with a Chinese network. Revenue per user is lower here.":"La Cina continentale gioca con regole tutte sue. {list} e altri servizi stranieri qui sono bloccati, quindi gli utenti raggiungono soprattutto reti cinesi. Il traffico che attraversa il confine perde circa il {pct} tra filtri e congestione, a meno che non viaggi su una rotta premium: transit CN-Too o un circuito transfrontaliero premium (entrambi venduti solo a Hong Kong), oppure un PNI con una rete cinese. Qui i ricavi per utente sono più bassi.",
"Foreign networks need a local joint venture and an operating license to build infrastructure here.":"Per costruire infrastrutture qui, le reti straniere hanno bisogno di una joint venture locale e di una licenza operativa.",
@ -2631,4 +2630,14 @@
"via a capacity broker":"tramite un broker di capacità",
"List it with a capacity broker <small>they keep 10%</small>":"Mettila in vendita con un broker di capacità <small>trattiene il 10%</small>",
"Nothing spare to sell on this fiber right now.":"Per ora non c’è niente da vendere su questa fibra.",
"Custom":"Personalizzata",
"Multiplier":"Moltiplicatore",
"Cost":"Costo",
"Set":"Imposta",
"Cost on this link: {w}. Allowed: {lo} to {hi}.":"Costo su questo link: {w}. Ammessi: da {lo} a {hi}.",
"Your routers pick the lowest-cost path. Raise the metric to push traffic onto other paths. “Backup only” keeps it idle unless nothing else works. Pick Custom to set your own multiplier or cost. Applies to every link between these two cities.":"I tuoi router scelgono il percorso a costo minore. Alza la metrica per spingere il traffico su altri percorsi. “Solo backup” lo lascia a riposo finché il resto funziona. Scegli Personalizzata per impostare il tuo moltiplicatore o costo. Vale per tutti i link tra queste due città.",
"A link’s cost is its length in km plus 60, times a multiplier. Traffic takes the path with the lowest total cost.":"Il costo di un link è la sua lunghezza in km più 60, per un moltiplicatore. Il traffico prende il percorso col costo totale più basso.",
"Presets on this link: {list}.":"Preset su questo link: {list}.",
"Cost: the exact number, whatever the distance.":"Costo: il numero esatto, a prescindere dalla distanza.",
"Multiplier: scales the distance cost, so a longer link still costs more.":"Moltiplicatore: scala il costo della distanza, così un link più lungo costa comunque di più.",
};