Merge remote-tracking branch 'origin/main' into claude/fix-228

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
Frederic Jung 2026-10-31 07:37:43 +01:00
commit caa979a671
No known key found for this signature in database
14 changed files with 60 additions and 9 deletions

View file

@ -7,6 +7,8 @@ All notable changes to this project are documented here. The project follows
## [Unreleased] ## [Unreleased]
- The intern's notes now name the exchanges it peered at: a city's first exchange showed as the city, so "Apfelwein-IX, London" really meant Apfelwein-IX and LYNX (#228). - The intern's notes now name the exchanges it peered at: a city's first exchange showed as the city, so "Apfelwein-IX, London" really meant Apfelwein-IX and LYNX (#228).
- Cancelling an IRU, giving up your own fiber or decommissioning a POP now puts the optics on its fibers back on the spares shelf, instead of throwing them away (#229).
- Big networks freeze for less on every game day and every click: working out where traffic goes skips exits whose route is already full, so a game day takes about 40% less time (#210). Traffic goes exactly where it went before.
- Premium submarine terminals and Optical engineering can no longer be bought on a cable where they would change nothing (#198). The button now says so, and an upgrade that only helps together with the other one stays available. - Premium submarine terminals and Optical engineering can no longer be bought on a cable where they would change nothing (#198). The button now says so, and an upgrade that only helps together with the other one stays available.
- A wave size that is sold out on a route can no longer be reached by upgrading a smaller wave on it (#201). The upgrade button says how long it is sold out, just like when buying. - A wave size that is sold out on a route can no longer be reached by upgrading a smaller wave on it (#201). The upgrade button says how long it is sold out, just like when buying.
- Choosing Both for a PNI with one member now really splits it: the second member arrives in the other building when the augment lands, instead of joining the first (#219). - Choosing Both for a PNI with one member now really splits it: the second member arrives in the other building when the augment lands, instead of joining the first (#219).

View file

@ -2447,6 +2447,7 @@
"links.fabric_port_in_city_is_full":"<b>Fabric-Port in {city} ist voll.</b>", "links.fabric_port_in_city_is_full":"<b>Fabric-Port in {city} ist voll.</b>",
"links.fixed_what_resolved_early":"<b>Repariert.</b> {what} vorzeitig behoben.", "links.fixed_what_resolved_early":"<b>Repariert.</b> {what} vorzeitig behoben.",
"links.ix_now_runs_a_fab_fabric":"<b>{ix} betreibt jetzt eine {fab}-Fabric.</b><br>Platz für {max} Mitglieder. Rechne mit ein paar weiteren Beitritten.", "links.ix_now_runs_a_fab_fabric":"<b>{ix} betreibt jetzt eine {fab}-Fabric.</b><br>Platz für {max} Mitglieder. Rechne mit ein paar weiteren Beitritten.",
"links.n_optic_back_on_the_spares_shelf":{"one":"{n} Optik ist zurück im Ersatzteilregal","other":"{n} Optiken sind zurück im Ersatzteilregal"},
"links.name_is_called_off_the_cable":"<b>{name} ist abgesagt.</b><br>Die Kabelfabrik nimmt das Glas zurück, das niemand braucht: {price} zurück.", "links.name_is_called_off_the_cable":"<b>{name} ist abgesagt.</b><br>Die Kabelfabrik nimmt das Glas zurück, das niemand braucht: {price} zurück.",
"links.no_cable_available_for_that_route":"<b>Für diese Route ist gerade kein Kabel verfügbar.</b>", "links.no_cable_available_for_that_route":"<b>Für diese Route ist gerade kein Kabel verfügbar.</b>",
"links.no_wave_capacity_on_this_route":"<b>Auf dieser Route gerade keine {wave}-Kapazität.</b><br>{why} Versuch eine kleinere Wave, eine andere Route oder frag in {n} Tagen nochmal.", "links.no_wave_capacity_on_this_route":"<b>Auf dieser Route gerade keine {wave}-Kapazität.</b><br>{why} Versuch eine kleinere Wave, eine andere Route oder frag in {n} Tagen nochmal.",

View file

@ -2445,6 +2445,7 @@
"links.fabric_port_in_city_is_full":"<b>El puerto de fabric en {city} está lleno.</b>", "links.fabric_port_in_city_is_full":"<b>El puerto de fabric en {city} está lleno.</b>",
"links.fixed_what_resolved_early":"<b>Arreglado.</b> {what} se resolvió antes.", "links.fixed_what_resolved_early":"<b>Arreglado.</b> {what} se resolvió antes.",
"links.ix_now_runs_a_fab_fabric":"<b>{ix} ahora tiene una fabric {fab}.</b><br>Hay sitio para {max} miembros. Espera que se unan algunos más.", "links.ix_now_runs_a_fab_fabric":"<b>{ix} ahora tiene una fabric {fab}.</b><br>Hay sitio para {max} miembros. Espera que se unan algunos más.",
"links.n_optic_back_on_the_spares_shelf":{"one":"{n} óptica volvió al estante de repuestos","other":"{n} ópticas volvieron al estante de repuestos"},
"links.name_is_called_off_the_cable":"<b>{name} se cancela.</b><br>La fábrica de cables recupera el vidrio que nadie necesita: te devuelve {price}.", "links.name_is_called_off_the_cable":"<b>{name} se cancela.</b><br>La fábrica de cables recupera el vidrio que nadie necesita: te devuelve {price}.",
"links.no_cable_available_for_that_route":"<b>Ahora mismo no hay cable disponible para esa ruta.</b>", "links.no_cable_available_for_that_route":"<b>Ahora mismo no hay cable disponible para esa ruta.</b>",
"links.no_wave_capacity_on_this_route":"<b>Ahora no hay capacidad de {wave} en esta ruta.</b><br>{why} Prueba una onda menor, otra ruta, o vuelve a preguntar en {n} días.", "links.no_wave_capacity_on_this_route":"<b>Ahora no hay capacidad de {wave} en esta ruta.</b><br>{why} Prueba una onda menor, otra ruta, o vuelve a preguntar en {n} días.",

View file

@ -2445,6 +2445,7 @@
"links.fabric_port_in_city_is_full":"<b>Le port fabric de {city} est plein.</b>", "links.fabric_port_in_city_is_full":"<b>Le port fabric de {city} est plein.</b>",
"links.fixed_what_resolved_early":"<b>Réparé.</b> {what} : résolu en avance.", "links.fixed_what_resolved_early":"<b>Réparé.</b> {what} : résolu en avance.",
"links.ix_now_runs_a_fab_fabric":"<b>{ix} tourne maintenant sur un fabric {fab}.</b><br>De la place pour {max} membres. Attends-toi à quelques nouveaux venus.", "links.ix_now_runs_a_fab_fabric":"<b>{ix} tourne maintenant sur un fabric {fab}.</b><br>De la place pour {max} membres. Attends-toi à quelques nouveaux venus.",
"links.n_optic_back_on_the_spares_shelf":{"one":"{n} optique est retournée sur l’étagère de rechange","other":"{n} optiques sont retournées sur l’étagère de rechange"},
"links.name_is_called_off_the_cable":"<b>{name} est annulé.</b><br>L’usine de câbles reprend le verre dont personne n’a besoin : {price} remboursés.", "links.name_is_called_off_the_cable":"<b>{name} est annulé.</b><br>L’usine de câbles reprend le verre dont personne n’a besoin : {price} remboursés.",
"links.no_cable_available_for_that_route":"<b>Aucun câble disponible pour cette route pour l’instant.</b>", "links.no_cable_available_for_that_route":"<b>Aucun câble disponible pour cette route pour l’instant.</b>",
"links.no_wave_capacity_on_this_route":"<b>Plus de capacité {wave} sur cette route pour l’instant.</b><br>{why} Essayez une onde plus petite, une autre route, ou redemandez dans {n} jours.", "links.no_wave_capacity_on_this_route":"<b>Plus de capacité {wave} sur cette route pour l’instant.</b><br>{why} Essayez une onde plus petite, une autre route, ou redemandez dans {n} jours.",

View file

@ -2445,6 +2445,7 @@
"links.fabric_port_in_city_is_full":"<b>La porta fabric a {city} è piena.</b>", "links.fabric_port_in_city_is_full":"<b>La porta fabric a {city} è piena.</b>",
"links.fixed_what_resolved_early":"<b>Sistemato.</b> {what}: risolto in anticipo.", "links.fixed_what_resolved_early":"<b>Sistemato.</b> {what}: risolto in anticipo.",
"links.ix_now_runs_a_fab_fabric":"<b>{ix} ora gira su un fabric {fab}.</b><br>Spazio per {max} membri. Aspettati qualche nuovo arrivo.", "links.ix_now_runs_a_fab_fabric":"<b>{ix} ora gira su un fabric {fab}.</b><br>Spazio per {max} membri. Aspettati qualche nuovo arrivo.",
"links.n_optic_back_on_the_spares_shelf":{"one":"{n} ottica è tornata sullo scaffale dei ricambi","other":"{n} ottiche sono tornate sullo scaffale dei ricambi"},
"links.name_is_called_off_the_cable":"<b>{name} è annullato.</b><br>La fabbrica di cavi si riprende il vetro che non serve a nessuno: {price} indietro.", "links.name_is_called_off_the_cable":"<b>{name} è annullato.</b><br>La fabbrica di cavi si riprende il vetro che non serve a nessuno: {price} indietro.",
"links.no_cable_available_for_that_route":"<b>Al momento non c’è nessun cavo disponibile per quella tratta.</b>", "links.no_cable_available_for_that_route":"<b>Al momento non c’è nessun cavo disponibile per quella tratta.</b>",
"links.no_wave_capacity_on_this_route":"<b>Nessuna capacità {wave} su questa tratta al momento.</b><br>{why} Prova un’onda più piccola, un’altra tratta, o chiedi di nuovo tra {n} giorni.", "links.no_wave_capacity_on_this_route":"<b>Nessuna capacità {wave} su questa tratta al momento.</b><br>{why} Prova un’onda più piccola, un’altra tratta, o chiedi di nuovo tra {n} giorni.",

View file

@ -2445,6 +2445,7 @@
"links.fabric_port_in_city_is_full":"<b>A porta de fabric em {city} está cheia.</b>", "links.fabric_port_in_city_is_full":"<b>A porta de fabric em {city} está cheia.</b>",
"links.fixed_what_resolved_early":"<b>Resolvido.</b> {what}: resolvido antes da hora.", "links.fixed_what_resolved_early":"<b>Resolvido.</b> {what}: resolvido antes da hora.",
"links.ix_now_runs_a_fab_fabric":"<b>{ix} agora roda num fabric {fab}.</b><br>Espaço para {max} membros. Espere mais alguns chegarem.", "links.ix_now_runs_a_fab_fabric":"<b>{ix} agora roda num fabric {fab}.</b><br>Espaço para {max} membros. Espere mais alguns chegarem.",
"links.n_optic_back_on_the_spares_shelf":{"one":"{n} óptico voltou para a prateleira de reservas","other":"{n} ópticos voltaram para a prateleira de reservas"},
"links.name_is_called_off_the_cable":"<b>{name} foi cancelado.</b><br>A fábrica de cabos pega de volta o vidro que ninguém precisa: {price} de volta.", "links.name_is_called_off_the_cable":"<b>{name} foi cancelado.</b><br>A fábrica de cabos pega de volta o vidro que ninguém precisa: {price} de volta.",
"links.no_cable_available_for_that_route":"<b>Nenhum cabo disponível para essa rota agora.</b>", "links.no_cable_available_for_that_route":"<b>Nenhum cabo disponível para essa rota agora.</b>",
"links.no_wave_capacity_on_this_route":"<b>Sem capacidade de {wave} nesta rota agora.</b><br>{why} Tente uma onda menor, outra rota, ou pergunte de novo em {n} dias.", "links.no_wave_capacity_on_this_route":"<b>Sem capacidade de {wave} nesta rota agora.</b><br>{why} Tente uma onda menor, outra rota, ou pergunte de novo em {n} dias.",

View file

@ -182,8 +182,8 @@ function compute(){
let V=L;if(NCOMP>1){const cs=[];for(const e of L){const k=COMP[e.ci];if(k>=0)(cs[k]||(cs[k]=[])).push(e);}for(const s of cs)if(s)idx(s);V={cs};}else idx(L);LIST.set(key,V);m[r]=V;}} let V=L;if(NCOMP>1){const cs=[];for(const e of L){const k=COMP[e.ci];if(k>=0)(cs[k]||(cs[k]=[])).push(e);}for(const s of cs)if(s)idx(s);V={cs};}else idx(L);LIST.set(key,V);m[r]=V;}}
// The flow being routed, and from its POP: distances, arriving edges and the paths walked so far, by city index. // The flow being routed, and from its POP: distances, arriving edges and the paths walked so far, by city index.
let f=null,Dv=null,Pv=null,PP=null,vis=0;const walked=[],G=[],REST=[],NEG=[]; let f=null,Dv=null,Pv=null,PP=null,vis=0;const walked=[],G=[],REST=[],NEG=[];
// An exit the flow can still try: not visited yet, not full when the flow started, and reachable from the POP. // An exit the flow can still try: not visited yet, not full when the flow started, reachable, and not on a saturated path.
const usable=e=>e.vis!==vis&&e.used<e.cap&&Dv[e.ci]<Infinity,byDist=(a,b)=>a.hp-b.hp||Dv[a.ci]-Dv[b.ci]; const usable=e=>e.vis!==vis&&e.used<e.cap&&Dv[e.ci]<Infinity&&!gone(e),byDist=(a,b)=>a.hp-b.hp||Dv[a.ci]-Dv[b.ci];
// Push up to `want` along one path to exit e; returns what fitted. Capacity only shrinks while routing, so a // Push up to `want` along one path to exit e; returns what fitted. Capacity only shrinks while routing, so a
// path with one full link or node fits nothing for the rest of this pass: mark it, and later tries cost nothing // path with one full link or node fits nothing for the rest of this pass: mark it, and later tries cost nothing
// (most tries are into paths that filled up earlier). // (most tries are into paths that filled up earlier).
@ -238,7 +238,7 @@ function compute(){
when it does not fit. Most often the group is the POP's own exits: with no preferred exit on the list when it does not fit. Most often the group is the POP's own exits: with no preferred exit on the list
and no other city at distance 0, the usable ones here are exactly the first group, already in order. */ and no other city at distance 0, the usable ones here are exactly the first group, already in order. */
G.length=0; G.length=0;
if(!lst.hi&&ALONE[f.ci]){const here=lst.at.get(f.ci);if(here)for(const e of here)if(e.used<e.cap)G.push(e);} if(!lst.hi&&ALONE[f.ci]){const here=lst.at.get(f.ci);if(here)for(const e of here)if(e.used<e.cap&&!gone(e))G.push(e);}
if(!G.length){ if(!G.length){
// One scan: the best (preference, distance) so far and, in list order, the exits within 1e-6 of it. The best // One scan: the best (preference, distance) so far and, in list order, the exits within 1e-6 of it. The best
// distance only goes down, so dropping the ones it leaves behind gives exactly the exits a second scan would. // distance only goes down, so dropping the ones it leaves behind gives exactly the exits a second scan would.
@ -247,9 +247,9 @@ function compute(){
them still have room no other exit can have become better, and the scan would find the same group (an them still have room no other exit can have become better, and the scan would find the same group (an
empty one, no usable exit, stays empty). */ empty one, no usable exit, stays empty). */
const gc=lst.gc||(lst.gc=[]),c=gc[f.ci]; const gc=lst.gc||(lst.gc=[]),c=gc[f.ci];
if(c!==undefined&&c.every(e=>e.used<e.cap)){if(!c.length)continue;for(let k=0;k<c.length;k++)G.push(c[k]);}else{ if(c!==undefined&&c.every(e=>e.used<e.cap&&!gone(e))){if(!c.length)continue;for(let k=0;k<c.length;k++)G.push(c[k]);}else{
let bh=2,bd=Infinity,full=0; let bh=2,bd=Infinity,full=0;
for(let li=0,LN=lst.length;li<LN;li++){const e=lst[li];if(e.used>=e.cap){full++;continue;}const d=Dv[e.ci];if(d===Infinity)continue;const h=e.hp; for(let li=0,LN=lst.length;li<LN;li++){const e=lst[li];if(e.used>=e.cap||gone(e)){full++;continue;}const d=Dv[e.ci];if(d===Infinity)continue;const h=e.hp;
if(h<bh){bh=h;bd=d;G.length=0;G.push(e);} if(h<bh){bh=h;bd=d;G.length=0;G.push(e);}
else if(h===bh){if(d<bd){bd=d;let k=0;for(let gi=0;gi<G.length;gi++){const x=G[gi];if(Dv[x.ci]-d<1e-6)G[k++]=x;}G.length=k;G.push(e);}else if(d-bd<1e-6)G.push(e);}} else if(h===bh){if(d<bd){bd=d;let k=0;for(let gi=0;gi<G.length;gi++){const x=G[gi];if(Dv[x.ci]-d<1e-6)G[k++]=x;}G.length=k;G.push(e);}else if(d-bd<1e-6)G.push(e);}}
if(full*4>=lst.length&&full){let k=0;for(let li=0;li<lst.length;li++){const e=lst[li];if(e.used<e.cap)lst[k++]=e;}lst.length=k;} if(full*4>=lst.length&&full){let k=0;for(let li=0;li<lst.length;li++){const e=lst[li];if(e.used<e.cap)lst[k++]=e;}lst.length=k;}

View file

@ -3,7 +3,8 @@ Object.assign(ACT,{
decomOpen:({city})=>{UI.decom=new Set(city&&S.pops[city]?[city]:[]);decomModal();}, decomOpen:({city})=>{UI.decom=new Set(city&&S.pops[city]?[city]:[]);decomModal();},
decomToggle:({city})=>{if(!S.pops[city])return;UI.decom=UI.decom||new Set();if(UI.decom.has(city))UI.decom.delete(city);else UI.decom.add(city);decomModal();}, decomToggle:({city})=>{if(!S.pops[city])return;UI.decom=UI.decom||new Set();if(UI.decom.has(city))UI.decom.delete(city);else UI.decom.add(city);decomModal();},
decomGo:()=>{const sel=[...(UI.decom||[])].filter(c=>S.pops[c]);if(!sel.length||sel.length>=Object.keys(S.pops).length)return;closeModal();UI.decom=null;UI.sel=null;decommission(sel);sfx('alert');after();}, decomGo:()=>{const sel=[...(UI.decom||[])].filter(c=>S.pops[c]);if(!sel.length||sel.length>=Object.keys(S.pops).length)return;closeModal();UI.decom=null;UI.sel=null;decommission(sel);sfx('alert');after();},
rmLink:({id})=>{if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}{const l=S.links.find(x=>x.id===id),back=cabBack(l);if(back>0){S.cash+=back;toast(tr('links.name_is_called_off_the_cable',{name:esc(l.cname||tr('common.your_cable')),price:fmt$(back)}),'good');}}S.links=S.links.filter(l=>l.id!==id);prunePairMet();UI.sel=null;UI.confirm=null;after();}, rmLink:({id})=>{if(UI.confirm!==id){UI.confirm=id;renderPanel();return;}{const l=S.links.find(x=>x.id===id),back=cabBack(l);if(back>0){S.cash+=back;toast(tr('links.name_is_called_off_the_cable',{name:esc(l.cname||tr('common.your_cable')),price:fmt$(back)}),'good');}
const n=chBack(l?[l]:[]);if(n)toast(trn('links.n_optic_back_on_the_spares_shelf',n),'good');}S.links=S.links.filter(l=>l.id!==id);prunePairMet();UI.sel=null;UI.confirm=null;after();},
// The chaos monkey takes a banana and goes home early (no bonus). // The chaos monkey takes a banana and goes home early (no bonus).
mkBanana:()=>{if(!mkOn())return;if(!spend(mkBananaCost()))return;S.stats.bananas=(S.stats.bananas||0)+1;mkLeave('banana');track('monkey_banana');after();}, mkBanana:()=>{if(!mkOn())return;if(!spend(mkBananaCost()))return;S.stats.bananas=(S.stats.bananas||0)+1;mkLeave('banana');track('monkey_banana');after();},
fixInc:({id})=>{const i=S.inc.find(x=>x.id===id);if(!i||!(i.cost>0))return;if(i.slow&&i.rushed)return;if(!spend(i.cost))return; fixInc:({id})=>{const i=S.inc.find(x=>x.id===id);if(!i||!(i.cost>0))return;if(i.slow&&i.rushed)return;if(!spend(i.cost))return;

View file

@ -12,6 +12,8 @@ function dfAllowed(a,b){if(isSub(a,b))return !!subDfCable(a,b);return cnCity(a)=
/* Optics you unplug go on a spares shelf instead of in the bin (#45): the next channel of that type uses a spare /* Optics you unplug go on a spares shelf instead of in the bin (#45): the next channel of that type uses a spare
for free (only the regen sites' transponders are new), or you sell it on eBuy for part of the price. */ for free (only the regen sites' transponders are new), or you sell it on eBuy for part of the price. */
const SPARE_RESALE=0.4,spareN=o=>(S&&S.spares&&S.spares[o])|0,spareValue=o=>Math.round(optCost(o)*SPARE_RESALE); const SPARE_RESALE=0.4,spareN=o=>(S&&S.spares&&S.spares[o])|0,spareValue=o=>Math.round(optCost(o)*SPARE_RESALE);
// A fiber given up (a cancelled IRU, a cable called off, a decommissioned POP) keeps its optics: they go on the shelf too (#229).
const chBack=links=>{let n=0;for(const l of links)for(const o of (l&&l.ch)||[])if(OPT[o]){S.spares=S.spares||{};S.spares[o]=(S.spares[o]||0)+1;n++;}return n;};
function chCost(l,o){const r=REGEN_CH*(l.regen|0);return Math.round(optCost(o)*(spareN(o)>0?r:1+r));} function chCost(l,o){const r=REGEN_CH*(l.regen|0);return Math.round(optCost(o)*(spareN(o)>0?r:1+r));}
function optCost(o){return Math.round(OPT[o].cost*techMul(OPT[o].lvl)*hwMul('opt')*(S&&S.ev&&S.ev.tariff>S.day?1.4:1));} function optCost(o){return Math.round(OPT[o].cost*techMul(OPT[o].lvl)*hwMul('opt')*(S&&S.ev&&S.ev.tariff>S.day?1.4:1));}
// Line systems upgrade in place: Rainbow → ROADMaster → C+L. Every lit pair gets the new gear. // Line systems upgrade in place: Rainbow → ROADMaster → C+L. Every lit pair gets the new gear.

View file

@ -13,10 +13,10 @@ function decomModal(){const sel=[...(UI.decom||[])],im=decomImpact(sel),all=Obje
${left<1?`<p class="why">${tr('decommission.keep_at_least_one_pop')}</p>`:''} ${left<1?`<p class="why">${tr('decommission.keep_at_least_one_pop')}</p>`:''}
<div class="btns" style="margin-top:10px">${btn(sel.length?trn('decommission.decommission_n_pop_pay_fee',sel.length,{fee:fmt$(im.fee)}):tr('decommission.pick_a_pop'),'decomGo',{},'red',!sel.length||left<1)}${btn(tr('common.keep_them'),'closeModal',{},'ghost')}</div>`);} <div class="btns" style="margin-top:10px">${btn(sel.length?trn('decommission.decommission_n_pop_pay_fee',sel.length,{fee:fmt$(im.fee)}):tr('decommission.pick_a_pop'),'decomGo',{},'red',!sel.length||left<1)}${btn(tr('common.keep_them'),'closeModal',{},'ghost')}</div>`);}
function decommission(cities){const set=new Set(cities),im=decomImpact(cities),lids=new Set(im.links.map(l=>l.id)),bids=new Set(im.biz.map(b=>b.id)); function decommission(cities){const set=new Set(cities),im=decomImpact(cities),lids=new Set(im.links.map(l=>l.id)),bids=new Set(im.biz.map(b=>b.id));
S.links=S.links.filter(l=>!lids.has(l.id));prunePairMet();S.biz=S.biz.filter(b=>!bids.has(b.id));S.offers=S.offers.filter(o=>!bCities(o).some(c=>set.has(c))); const back=chBack(im.links);S.links=S.links.filter(l=>!lids.has(l.id));prunePairMet();S.biz=S.biz.filter(b=>!bids.has(b.id));S.offers=S.offers.filter(o=>!bCities(o).some(c=>set.has(c)));
S.transit=S.transit.filter(t=>!set.has(t.city));S.pni=S.pni.filter(x=>!set.has(x.city));S.caches=S.caches.filter(x=>!set.has(x.city));S.nni=(S.nni||[]).filter(x=>!set.has(x.city)); S.transit=S.transit.filter(t=>!set.has(t.city));S.pni=S.pni.filter(x=>!set.has(x.city));S.caches=S.caches.filter(x=>!set.has(x.city));S.nni=(S.nni||[]).filter(x=>!set.has(x.city));
for(const c of cities){for(const x of ixIdsIn(c)){delete S.ixp[x];delete S.rs[x];if(S.ixn)delete S.ixn[x];if(S.ixSite)delete S.ixSite[x];for(const k in S.peers)if(k.endsWith('@'+x))delete S.peers[k];}delete S.myIx[c];S.scrubs=S.scrubs.filter(x=>x.city!==c);if(S.ops)delete S.ops.skip[c];delete S.pops[c];} for(const c of cities){for(const x of ixIdsIn(c)){delete S.ixp[x];delete S.rs[x];if(S.ixn)delete S.ixn[x];if(S.ixSite)delete S.ixSite[x];for(const k in S.peers)if(k.endsWith('@'+x))delete S.peers[k];}delete S.myIx[c];S.scrubs=S.scrubs.filter(x=>x.city!==c);if(S.ops)delete S.ops.skip[c];delete S.pops[c];}
const rem=remoteCities();for(const x in S.ixp){const c=ixCity(x);if(!S.pops[c]&&!rem.includes(c)){delete S.ixp[x];delete S.rs[x];for(const k in S.peers)if(k.endsWith('@'+x))delete S.peers[k];}} const rem=remoteCities();for(const x in S.ixp){const c=ixCity(x);if(!S.pops[c]&&!rem.includes(c)){delete S.ixp[x];delete S.rs[x];for(const k in S.peers)if(k.endsWith('@'+x))delete S.peers[k];}}
if(set.has(S.home))S.home=Object.keys(S.pops)[0]; if(set.has(S.home))S.home=Object.keys(S.pops)[0];
purgeInc();S.cash-=im.fee;S.stats.decom=(S.stats.decom||0)+cities.length; purgeInc();S.cash-=im.fee;S.stats.decom=(S.stats.decom||0)+cities.length;
toast(trn('decommission.n_pop_decommissioned_fee_in_early',cities.length,{fee:fmt$(im.fee),m:im.biz.length}),'bad');} toast(trn('decommission.n_pop_decommissioned_fee_in_early',cities.length,{fee:fmt$(im.fee),m:im.biz.length}),'bad');if(back)toast(trn('links.n_optic_back_on_the_spares_shelf',back),'good');}

View file

@ -2446,6 +2446,7 @@
"links.fabric_port_in_city_is_full":"<b>Fabric port in {city} is full.</b>", "links.fabric_port_in_city_is_full":"<b>Fabric port in {city} is full.</b>",
"links.fixed_what_resolved_early":"<b>Fixed.</b> {what} resolved early.", "links.fixed_what_resolved_early":"<b>Fixed.</b> {what} resolved early.",
"links.ix_now_runs_a_fab_fabric":"<b>{ix} now runs a {fab} fabric.</b><br>Room for {max} members. Expect a few more to join.", "links.ix_now_runs_a_fab_fabric":"<b>{ix} now runs a {fab} fabric.</b><br>Room for {max} members. Expect a few more to join.",
"links.n_optic_back_on_the_spares_shelf":{"one":"{n} optic went back on the spares shelf","other":"{n} optics went back on the spares shelf"},
"links.name_is_called_off_the_cable":"<b>{name} is called off.</b><br>The cable factory takes back the glass nobody needs: {price} back.", "links.name_is_called_off_the_cable":"<b>{name} is called off.</b><br>The cable factory takes back the glass nobody needs: {price} back.",
"links.no_cable_available_for_that_route":"<b>No cable available for that route right now.</b>", "links.no_cable_available_for_that_route":"<b>No cable available for that route right now.</b>",
"links.no_wave_capacity_on_this_route":"<b>No {wave} capacity on this route right now.</b><br>{why} Try a smaller wave, another route, or ask again in {n} days.", "links.no_wave_capacity_on_this_route":"<b>No {wave} capacity on this route right now.</b><br>{why} Try a smaller wave, another route, or ask again in {n} days.",

View file

@ -1,12 +1,14 @@
// Deliberately scan all exits for every flow, without byRank, local-city // Deliberately scan all exits for every flow, without byRank, local-city
// shortcuts or first-group selection. Stable sorting preserves E order on ties. // shortcuts or first-group selection. Stable sorting preserves E order on ties.
// Without Auto-TE, an exit whose shortest path from this POP is already full fits nothing, so it counts as
// unusable, like a full exit (#210).
module.exports = ` module.exports = `
for(const pass of PASSES||[null])for(const rank of RANKS){ for(const pass of PASSES||[null])for(const rank of RANKS){
for(f of flows){ for(f of flows){
if(f.rem<=1e-6||(rank===0&&!f.cache)||(pass&&!pass(f)))continue; if(f.rem<=1e-6||(rank===0&&!f.cache)||(pass&&!pass(f)))continue;
Dv=SDi[f.ci];Pv=SPi[f.ci];PP=walked[f.ci]||(walked[f.ci]=[]);vis++; Dv=SDi[f.ci];Pv=SPi[f.ci];PP=walked[f.ci]||(walked[f.ci]=[]);vis++;
const candidates=E.filter(e=>e.used<e.cap&&e.ok(f.n)&& const candidates=E.filter(e=>e.used<e.cap&&e.ok(f.n)&&
(TR?eff(e,f.n):base(e,f.n))===rank&&Dv[CIDX[e.city]]<Infinity) (TR?eff(e,f.n):base(e,f.n))===rank&&Dv[CIDX[e.city]]<Infinity&&!gone(e))
.sort((a,b)=>(a.pref==='high'?0:1)-(b.pref==='high'?0:1)||Dv[CIDX[a.city]]-Dv[CIDX[b.city]]); .sort((a,b)=>(a.pref==='high'?0:1)-(b.pref==='high'?0:1)||Dv[CIDX[a.city]]-Dv[CIDX[b.city]]);
for(let i=0;i<candidates.length&&f.rem>1e-6;){ for(let i=0;i<candidates.length&&f.rem>1e-6;){
let j=i+1;while(j<candidates.length&&(candidates[j].pref==='high')===(candidates[i].pref==='high')&& let j=i+1;while(j<candidates.length&&(candidates[j].pref==='high')===(candidates[i].pref==='high')&&

View file

@ -1381,3 +1381,19 @@ test('#219 choosing one site again while the augment is on order keeps the LAG i
assert.equal(ev('S.pni[0].site'), 'b'); assert.equal(ev('S.pni[0].site'), 'b');
assert.deepEqual(errors, []); assert.deepEqual(errors, []);
}); });
test('#210 candidate exits on saturated shortest paths are skipped to avoid fallback churn', () => {
const { ev, errors } = load();
ev("ACT.start({});S.cash=1e8;UI.speed=0;for(const g of GOALS)S.done[g.id]=0;");
ev("ACT.buyTransit({city:'fra',net:'cog',tier:1});");
ev("ACT.buildPop({city:'par'});ACT.launchBB({city:'par'});");
ev("S.links.push({id:'x1',a:'fra',b:'par',kind:'wave',tier:0,km:450,mult:1,mo:1000,ready:0,cut:0});");
ev("compute();");
assert.ok(ev("R.load['x1'] >= 10 - 1e-6"), 'intercity wave is saturated');
assert.ok(ev("R.load['x1'] <= 10 + 1e-6"), 'and carries no more than it can');
// Skipping exits behind the full wave changes nothing: routing again gives the same answer.
const first = ev('JSON.stringify([R.served,R.citySrv,R.load])');
ev("compute();");
assert.equal(ev('JSON.stringify([R.served,R.citySrv,R.load])'), first);
assert.deepEqual(errors, []);
});

View file

@ -79,3 +79,25 @@ test('draft counts and quotes stay together when reopening a panel or using shor
assert.equal(field().value,'','empty in-progress entry survives a tick'); assert.equal(field().value,'','empty in-progress entry survives a tick');
}finally{dom.window.close();} }finally{dom.window.close();}
}); });
test('#229 giving up a fiber puts its optics on the spares shelf, and so does decommissioning its POP',()=>{
const {ev,dom,errors}=load();try{
setup(ev);
// a leased IRU (not your own build) with mixed optics
ev("Object.assign(S.links[0],{own:false,ch:['zr4','zr4','tp16']});S.spares={zr4:1};compute()");
ev("ACT.rmLink({id:'fiber'})");assert.equal(ev('S.links.length'),1,'the first click only asks');
ev("ACT.rmLink({id:'fiber'})");assert.equal(ev('S.links.length'),0,'cancelled');
assert.equal(ev('S.spares.zr4'),3);assert.equal(ev('S.spares.tp16'),1);
assert.match(ev("S.log.map(e=>e.t).join(' | ')"),/3 optics went back on the spares shelf/);
// the next channel of that type uses a spare for free
ev("S.links.push({id:'f2',a:'fra',b:'ams',kind:'df',own:true,sys:'roadm',km:400,ch:[],ready:0,day:0,cut:0,mo:1});compute()");
const cash=ev('S.cash');ev("ACT.setChCount({id:'f2',o:'zr4',n:3})");assert.equal(ev('S.cash'),cash,'spares are used first');assert.equal(ev('S.spares.zr4'),0);
// decommissioning a POP returns the optics of every link it takes with it
ev("S.pops.lon={...S.pops.fra};S.links.push({id:'f3',a:'lon',b:'ams',kind:'df',own:true,sys:'roadm',km:400,ch:['tp16','tp16'],ready:0,day:0,cut:0,mo:1});compute()");
ev("decommission(['lon'])");
assert.equal(ev("S.links.some(l=>l.id==='f3')"),false);assert.equal(ev('S.spares.tp16'),3);
// a link without optics says nothing about spares
ev("S.log=[];S.links.push({id:'f4',a:'fra',b:'ams',kind:'df',own:true,sys:'roadm',km:400,ch:[],ready:0,day:0,cut:0,mo:1});compute();ACT.rmLink({id:'f4'});ACT.rmLink({id:'f4'})");
assert.doesNotMatch(ev("S.log.map(e=>e.t).join(' | ')"),/spares shelf/);
assert.deepEqual(errors,[]);
}finally{dom.window.close();}
});