From 935c08839fc4db969e6a40b859781d7f2745a016 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Sun, 1 Nov 2026 18:36:52 +0100 Subject: [PATCH] Clicks that change nothing routing reads keep their routing (loans do reroute); CHANGELOG corrected --- CHANGELOG.md | 4 +- src/game/90-actions/90-action-helpers.js | 8 +++- tests/route-skip.test.js | 47 ++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 tests/route-skip.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index a22a7d5..8a496e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +- On big networks, clicks that change nothing about your traffic now answer at once: dismissing an offer or renaming your network no longer works out every route again, which also saves battery on phones. +- Working out where traffic goes takes about a fifth less work on big networks, with exactly the same result. - The game no longer freezes while it routes each day's traffic on big networks. A background thread of the game does the routing, so the map, panels and buttons keep responding while days go by; what the day brings is exactly what it was before. Clicks that change your network still route right away. ## [2.4.0] — 2026-11-01 @@ -14,7 +16,7 @@ All notable changes to this project are documented here. The project follows - Doitsche Telekomm and Tangerine Telecom are now Tier 1s, as in real life (#194). In new games, going transit-free means a PNI with both of them too; games you already started keep the Tier 1s they were playing for. Doitsche now sells transit at the highest price in Europe and still charges for peering, and like the other Tier 1s, Tangerine now starts its PNIs at 100G. - Cache boxes now share router ports through an aggregation switch: one port carries as many 100G boxes as its speed holds, so 32 fit on a 3.2T port (#252). Each site gets its own. - Pick a standard POP: in any POP's Infra tab, make its routers the standard, and every new POP gets that model and number of routers right away, while it is still empty (#240). -- Big networks run faster: routing skips traffic it has already placed, the map skips links off screen without working out their shape, and the Networks tab and the zoomed-in map draw faster. Where traffic goes does not change. +- Big networks run faster: the map skips links off screen without working out their shape, and the Networks tab and the zoomed-in map draw faster. Where traffic goes does not change. - A network the game once failed to load is no longer stuck as damaged: the next version of the game tries it again, and its menu has a Try again button. Before, it could only be exported or deleted, even after the cause was fixed. - Save files of very large networks import again: the limit went from 8 MB to 64 MB. - 400G cache boxes: a POP whose routers have 400G or faster ports now gets 400G boxes, at $1,000 a month instead of $400 for 100G, so big caches need fewer boxes and cost less per Gbps. Boxes you already have stay as they are. diff --git a/src/game/90-actions/90-action-helpers.js b/src/game/90-actions/90-action-helpers.js index 96f1222..dac437f 100644 --- a/src/game/90-actions/90-action-helpers.js +++ b/src/game/90-actions/90-action-helpers.js @@ -24,7 +24,13 @@ function chWhy(l,o){const O=OPT[o];if(!techOk('opt',o,O.lvl))return tr('action_h if((l.ch||[]).length+soldSlots(l)>=chMax(l))return soldSlots(l)?tr('action_helpers.sys_is_full_max_channels_sold',{sys:DF_SYS[l.sys].n,max:chMax(l),sold:soldSlots(l)}):tr('action_helpers.sys_is_full_max_channels',{sys:DF_SYS[l.sys].n,max:chMax(l)}); for(const c of [l.a,l.b]){const p=S.pops[c];if(p&&RG[p.rgen||0].clsinnerWidth>760&&innerWidth<=1200; function selectLink(id){UI.sel={type:'link',id};UI.confirm=null;if(isTablet()||isPhone())UI.leftOpen=false;$('panel').classList.remove('full');renderPanel();renderLeft();} // Frame the whole drawn line (cables bend far from the straight one) in the part of the map the panel leaves free: diff --git a/tests/route-skip.test.js b/tests/route-skip.test.js new file mode 100644 index 0000000..1a3a649 --- /dev/null +++ b/tests/route-skip.test.js @@ -0,0 +1,47 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); +const { load } = require('./harness'); + +const SAVE = fs.readFileSync(path.join(__dirname, 'fixtures', 'big-network.json'), 'utf8'); +const big = (ev) => ev(`S=migrate(JSON.parse(${JSON.stringify(SAVE)}));UI.started=true;UI.pitched=true;UI.speed=0;closeModal();compute()`); +// Everything a player sees from routing: totals, money, every link, port and city. +const digest = "JSON.stringify([R.served,R.demand,R.reach,R.peered,R.revMo,R.costMo,R.cost,R.egT,R.load,R.useT,R.usePni,R.useIx,R.useCache,R.citySrv,R.cityDem])"; + +test('a field routing never reads really changes nothing it gives (every key the shortcut skips)', () => { + const { ev, errors } = load({ seed: 3 }); + big(ev); + const base = ev(digest); + const keys = JSON.parse(ev('JSON.stringify([...RK_SKIP])')); + for (const k of keys) { + // Change the field all through: every number moves, every flag flips, text changes, lists grow, objects gain a field. + ev(`(()=>{const m=x=>x==null?1:typeof x==='number'?x+12345:typeof x==='string'?x+'x':typeof x==='boolean'?!x:Array.isArray(x)?x.map(m).concat(x.length?[m(x[0])]:[]):Object.assign(Object.fromEntries(Object.entries(x).map(([a,b])=>[a,m(b)])),{zz:1});const v=S[${JSON.stringify(k)}];window.__k=[${JSON.stringify(k)},v];S[${JSON.stringify(k)}]=m(JSON.parse(JSON.stringify(v===undefined?null:v)));compute();})()`); + assert.equal(ev(digest), base, `routing reads S.${k}: take it off RK_SKIP`); + ev('S[__k[0]]=__k[1];compute()'); + } + assert.deepEqual(errors, []); +}); + +test('clicks that change nothing routing reads skip routing; real changes route again', () => { + const { ev, errors } = load(); + big(ev); + ev('window.__n=0;const _c=compute;compute=function(){__n++;return _c.apply(this,arguments)}'); + ev('after()'); + ev('__n=0;after();S.log.push({d:S.day,t:"x"});after();S.cash+=1000;after()'); + assert.equal(ev('__n'), 0, 'the log and cash do not reroute'); + ev("S.transit[0].pref='low';after()"); + assert.equal(ev('__n'), 1, 'a port setting does'); + ev('R=Object.assign({},R);after()'); + assert.equal(ev('__n'), 2, 'and so does a routing result from elsewhere (a day, the worker)'); + assert.deepEqual(errors, []); +}); + +test('routing never even reads a field the shortcut skips (so an empty one cannot hide it)', () => { + const { ev, errors } = load(); + big(ev); + const read = JSON.parse(ev(`(()=>{const seen=new Set(),real=S;S=new Proxy(real,{get(t,k){if(typeof k==='string')seen.add(k);return t[k];}});try{compute();}finally{S=real;}return JSON.stringify([...seen]);})()`)); + assert.deepEqual(read.filter((k) => ev(`RK_SKIP.has(${JSON.stringify(k)})`)), [], 'routing reads these: take them off RK_SKIP'); + assert.ok(read.includes('loans'), 'loans pay into the month, so routing reads them'); + assert.deepEqual(errors, []); +});