Submarine upgrades that change nothing on a cable can't be bought (#198)

Premium submarine terminals and Optical engineering only extend the
long-haul modes of the coherent optics. On many cable lengths (all of
the Atlantic, and about 17,000-18,500 km like Atlanta to Sydney) neither
changes what any optic carries, yet both could be bought.

subHelps() compares every optic's rate with and without the upgrade,
counting an upgrade that only helps together with the other one. The
link panel disables Install with a note, ACT.subUpgrade refuses, and
the cable order screen disables the toggle and only quotes and charges
picks that still help on the chosen design.
This commit is contained in:
Frederic Jung 2026-10-29 01:57:32 +00:00
parent 48e6200c53
commit f4c8400df1
No known key found for this signature in database
14 changed files with 127 additions and 20 deletions

View file

@ -53,6 +53,10 @@ const subMaxTier=km=>{let t=0;LT.forEach((T,i)=>{if(!subWaveWhy(i,km,true))t=i;}
// What an optic carries depends only on the optic, the span length and subsea or not; the map and compute() ask a lot.
// Cached per optic, span and cable state: subsea, and which submarine upgrades are in service (#78).
const OPTG={};const optG=(o,l)=>{const km=spanKm(l),fl=l.sub?1+(subUpgradeReady(l,'terminal')?2:0)+(subUpgradeReady(l,'engineering')?4:0):0,c=OPTG[o]||(OPTG[o]=[]),m=c[fl]||(c[fl]=new Map());let g=m.get(km);if(g===undefined){const x=optMode(o,l);m.set(km,g=x?x.g:0);}return g;};
// Whether upgrade k changes what any optic carries on a subsea cable this long (#198). has: the other upgrade is
// already in; otherwise k also counts when it only helps together with the other one.
const subOther=k=>k==='terminal'?'engineering':'terminal',subHelps=(km,k,has)=>{const j=subOther(k),c=(on,o)=>({kind:'df',own:true,sub:true,km,['sub'+k]:on?0:undefined,['sub'+j]:o?0:undefined});
return (has?[1]:[0,1]).some(o=>Object.keys(OPT).some(x=>optG(x,c(1,o))!==optG(x,c(0,o))));};
const regenNeed=(o,l)=>Math.max(0,Math.ceil(l.km/OPT[o].reach)-1);
// The map asks for every fiber's capacity several times per frame (width, colour, label, up or down), each time over
// all its channels. Nothing changes while a frame is drawn, so draw() keeps the answers in DFC for that frame.