Some checks are pending
CI / plan (push) Waiting to run
CI / part (push) Blocked by required conditions
CI / build (push) Waiting to run
CI / translations (push) Waiting to run
CI / test (push) Blocked by required conditions
CI / timings (push) Blocked by required conditions
Container image / gate (push) Waiting to run
Container image / test (push) Blocked by required conditions
Container image / publish (push) Blocked by required conditions
CHANGELOG.md: upstream's released sections as they are; main's 11 Unreleased bullets kept under Unreleased. scripts/lib/route-fuzz.js: upstream's skip of dashboard tabs the base lacks, plus main's trimming of args the base's buttons lack. src/game/10-catalog/40-ports.js: upstream's one-pass portsAt(); an express still takes ports per channel at its ends. src/game/10-catalog/60-reach-and-subsea.js: upstream's dfLit/dfCap0/dfOn (managed waves carved out); capOf() keeps xp and sat. src/game/60-features/80-new-game.js: upstream's vol and cm in a new game, with main's ip4, rgen, mp and saved-shape fields. src/game/60-features/95-standing-orders.js: upstream's portsAt, cachePlan and promiseCheck, inside main's build-standard routers order, optup marks, opsDarkPre and decom gone list; opsPairs still leaves satellites out. src/game/80-simulation/30-compute.js: upstream's routing core; main's satellite edges (SATN) pass into it, express risks and sat/ip4 money stay. src/game/80-simulation/29-route-core.js: main's satellite latency note moved into the core, where upstream moved the flow loop. src/game/80-simulation/40-billing.js: main's linkCut() and xp/sat in linkDown(), with upstream's dfOn(). src/game/80-simulation/50-sanitize.js: upstream's cmClean listings and cmFix/volFix; main keeps the xp/sat kinds, mpSanitize, ip4Fix and satSanitize. src/game/80-simulation/60-requirements.js: upstream's shared diversity graph; an express link carries the list of trenches it rides. src/game/91-save.js: upstream's saves in the worker, except a multiplayer session network, whose text is made on the page (mpSave) so the server gets the very save the slot holds; bootNotes() kept. src/game/91-slots.js: upstream's slot text and day, with main's mp badge on a slot. src/game/93-ui/70-link-panels.js: a fiber says both its managed waves and the expresses it carries. src/game/94-dashboard/60-dashboard.js: upstream's carried tile, main's themed demand line. src/game/95-modals/70-link-modal.js: main's Express tab, then upstream's hint for a coast no cable lands on (#321). After the merge: - Moving a circuit: a path over an express shares the trenches of the fibers it rides, so it is never called fully diverse from a path along them (test in express-fiber). - The capacity market and moving customers leave the slots expresses hold (test in express-fiber; no code change needed). - The NOC log keeps only the kinds a reload keeps: the market's info/warn news is a plain line, live as after a reload. - New acts classified for server-run play: market and path moves sent, marketOpen and pathOpen local; pathPin's path may be longer than 64 characters. - Server-play fixtures written again (new cm and vol fields); the dark-mode test reads mapStill()'s three states. - A big multiplayer network that moved on still pushes its save to the server (test in multiplayer). - The full suite ran on jsdom 31.0.0 and playwright-core 1.65.0, the versions the merged lockfile pins.
38 lines
4.1 KiB
JavaScript
38 lines
4.1 KiB
JavaScript
/* Single and bulk orders share the same checks, prices and provisioning. */
|
|
// at: for a batch, where to look up the PNI there already is and the ports in use, which the batch itself never changes.
|
|
function pniQuote(city,net,tier,reserved=0,at=null){tier=+tier;const g1=tier===-1;if(g1)tier=0;
|
|
if(!S||!S.pops[city]||!isNet(net)||!NET[net].pops.includes(city)||!Number.isInteger(tier)||!PORT[tier]||(g1&&!pniG1(net)))return null;
|
|
const ex=at?at.ex(city,net):S.pni.find(p=>p.city===city&&p.net===net),used=at?at.used:portsUsed;
|
|
if(ex&&(g1||!pniOn(ex)||ex.up||(!(ex.g1&&tier===0)&&tier<=ex.tier)))return null;
|
|
const cost=g1?PNI_G1_COST:(1500+PORT[tier].setup/2)*(ex&&ex.n||1),slots=ex?(PORT_SLOT(tier)-PORT_SLOT(ex.tier))*(ex.n||1):PORT_SLOT(tier);
|
|
let why='';if(!portOk(city,tier))why=tr('actions.your_router_can_t_take_a',{port:PORT[tier].n});
|
|
else{const r=peerOk(net,'pni',city);if(!r.ok)why=tr('sites_peering_caches.net_declined_the_pni_why',{net:esc(NET[net].name),why:esc(r.why)});
|
|
else if(!g1&&tier<pniMin(net))why=tr('sites_peering_caches.net_does_not_do_port_pnis',{net:esc(NET[net].name),port:PORT[tier].n});
|
|
else if(slots>0&&used(city)+reserved+slots>portsMax(city)+1e-9)why=tr('ports.no_free_router_ports_in_city',{city:esc(CITY[city].name),u:fmtPorts(used(city)+reserved),m:portsMax(city)});}
|
|
return {city,net,tier,g1,ex,cost,slots,why};}
|
|
// A new PNI has every field sanitize() gives one, so live S is what a reload makes of it.
|
|
function pniPlace(q){const {city,net,tier,g1,ex}=q,lead=pniLead(net);
|
|
if(S.conf&&S.conf.until>S.day)S.stats.beerPni=1;
|
|
if(ex){ex.up={tier,n:ex.n||1,ready:S.day+lead,g1:false};if(!lead)pniUpDone(ex);}else S.pni.push({id:uid(),city,net,tier,g1:g1||undefined,ready:S.day+lead,lacp:null,site:'a',n:1,sacrif:false});
|
|
return lead;}
|
|
// The ports a pending augment will add, and those of every pending augment at a city: what an order there must leave free.
|
|
const pniUpSlots=p=>Math.max(0,PORT_SLOT(p.up.tier)*(p.up.n||1)-PORT_SLOT(p.tier)*(p.n||1));
|
|
const pniResv=c=>{let r=0;for(const p of S.pni)if(p.up&&p.city===c)r+=pniUpSlots(p);return r;};
|
|
// A batch's order quoted again on the game as it is now: null if it no longer stands (ordered by hand meanwhile, say).
|
|
// Earlier orders of the batch, placed by now, are in the PNIs themselves: the same ports the batch reserved for them.
|
|
const pniRequote=q=>{const n=pniQuote(q.city,q.net,q.g1?-1:q.tier,pniResv(q.city));return n&&!n.why&&n.ex===q.ex?n:null;};
|
|
function pniBatch(net,tier){const g=pniBatchRun(net,tier);for(;;){const s=g.next();if(s.done)return s.value;}}
|
|
// The same batch with a place to let a frame through every few networks: the intern's weekly round (95-standing-orders.js).
|
|
function* pniBatchRun(net,tier){tier=+tier;const all=net===null;if(!S||(!all&&!isNet(net))||!Number.isInteger(tier)||(tier===-1?all||!pniG1(net):!PORT[tier]||!portShown(tier)))return null;
|
|
const shared=[],orders=[],blocked=[],reserved={};let kept=0,cost=0,mo=0,raised=0;
|
|
// Asked of every network at every shared POP: the PNIs by POP and network (the first one, as find() would), and the
|
|
// ports in use, counted for every POP in one pass the first time a quote needs them.
|
|
const exs=new Map();let use=null;for(const p of S.pni){const k=p.city+'|'+p.net;if(!exs.has(k))exs.set(k,p);}
|
|
const at={ex:(c,n)=>exs.get(c+'|'+n),used:c=>(use||(use=portsAt(Object.keys(S.pops)))).get(c)};
|
|
// Pending augments and earlier orders in this batch already own their future ports.
|
|
for(const p of S.pni)if(p.up)reserved[p.city]=(reserved[p.city]||0)+pniUpSlots(p);
|
|
let nn=0;for(const n of all?NETS:[NET[net]]){if(++nn%16===0)yield;for(const city of n.pops){if(!S.pops[city])continue;shared.push(city);
|
|
// Each network at its own minimum: asking everyone for 10G orders 100G from those that start at 100G.
|
|
const q=pniQuote(city,n.id,all&&tier>=0?Math.max(tier,pniMin(n.id)):tier,reserved[city]||0,at);if(!q){kept++;continue;}if(q.why){blocked.push(q);continue;}orders.push(q);if(q.tier>tier&&!q.g1)raised++;cost+=q.cost;reserved[city]=(reserved[city]||0)+q.slots;
|
|
mo+=pniMo({net:n.id,tier:q.tier,g1:q.g1,n:q.ex&&q.ex.n},0)-(q.ex?pniMo(q.ex,0):0);}}
|
|
return {shared,orders,blocked,kept,cost,mo,raised};}
|